棄用 API

最後更新


依「從哪個版本開始棄用」列出標準庫中所有標記為 #[deprecated] 的穩定 API;棄用的 API 仍可編譯(會出現警告),但官方建議改用說明中的替代做法,本書範例一律不使用。
棄用版本取自官方文件標示的「Deprecated since」;尚未決定版本(TBD,未來才會棄用)的 API 不列入。

Rust 1.99


Rust 1.99 版本頁
模組項目官方說明
stdi128::max_valuereplaced by the MAX associated constant on this type
stdi128::min_valuereplaced by the MIN associated constant on this type
stdi16::max_valuereplaced by the MAX associated constant on this type
stdi16::min_valuereplaced by the MIN associated constant on this type
stdi32::max_valuereplaced by the MAX associated constant on this type
stdi32::min_valuereplaced by the MIN associated constant on this type
stdi64::max_valuereplaced by the MAX associated constant on this type
stdi64::min_valuereplaced by the MIN associated constant on this type
stdi8::max_valuereplaced by the MAX associated constant on this type
stdi8::min_valuereplaced by the MIN associated constant on this type
stdisize::max_valuereplaced by the MAX associated constant on this type
stdisize::min_valuereplaced by the MIN associated constant on this type
stdu128::max_valuereplaced by the MAX associated constant on this type
stdu128::min_valuereplaced by the MIN associated constant on this type
stdu16::max_valuereplaced by the MAX associated constant on this type
stdu16::min_valuereplaced by the MIN associated constant on this type
stdu32::max_valuereplaced by the MAX associated constant on this type
stdu32::min_valuereplaced by the MIN associated constant on this type
stdu64::max_valuereplaced by the MAX associated constant on this type
stdu64::min_valuereplaced by the MIN associated constant on this type
stdu8::max_valuereplaced by the MAX associated constant on this type
stdu8::min_valuereplaced by the MIN associated constant on this type
stdusize::max_valuereplaced by the MAX associated constant on this type
stdusize::min_valuereplaced by the MIN associated constant on this type
std::f32DIGITSreplaced by the DIGITS associated constant on f32
std::f32EPSILONreplaced by the EPSILON associated constant on f32
std::f32INFINITYreplaced by the INFINITY associated constant on f32
std::f32MANTISSA_DIGITSreplaced by the MANTISSA_DIGITS associated constant on f32
std::f32MAXreplaced by the MAX associated constant on f32
std::f32MAX_10_EXPreplaced by the MAX_10_EXP associated constant on f32
std::f32MAX_EXPreplaced by the MAX_EXP associated constant on f32
std::f32MINreplaced by the MIN associated constant on f32
std::f32MIN_10_EXPreplaced by the MIN_10_EXP associated constant on f32
std::f32MIN_EXPreplaced by the MIN_EXP associated constant on f32
std::f32MIN_POSITIVEreplaced by the MIN_POSITIVE associated constant on f32
std::f32NANreplaced by the NAN associated constant on f32
std::f32NEG_INFINITYreplaced by the NEG_INFINITY associated constant on f32
std::f32RADIXreplaced by the RADIX associated constant on f32
std::f64DIGITSreplaced by the DIGITS associated constant on f64
std::f64EPSILONreplaced by the EPSILON associated constant on f64
std::f64INFINITYreplaced by the INFINITY associated constant on f64
std::f64MANTISSA_DIGITSreplaced by the MANTISSA_DIGITS associated constant on f64
std::f64MAXreplaced by the MAX associated constant on f64
std::f64MAX_10_EXPreplaced by the MAX_10_EXP associated constant on f64
std::f64MAX_EXPreplaced by the MAX_EXP associated constant on f64
std::f64MINreplaced by the MIN associated constant on f64
std::f64MIN_10_EXPreplaced by the MIN_10_EXP associated constant on f64
std::f64MIN_EXPreplaced by the MIN_EXP associated constant on f64
std::f64MIN_POSITIVEreplaced by the MIN_POSITIVE associated constant on f64
std::f64NANreplaced by the NAN associated constant on f64
std::f64NEG_INFINITYreplaced by the NEG_INFINITY associated constant on f64
std::f64RADIXreplaced by the RADIX associated constant on f64
std::i128MAXreplaced by the MAX associated constant on this type
std::i128MINreplaced by the MIN associated constant on this type
std::i16MAXreplaced by the MAX associated constant on this type
std::i16MINreplaced by the MIN associated constant on this type
std::i32MAXreplaced by the MAX associated constant on this type
std::i32MINreplaced by the MIN associated constant on this type
std::i64MAXreplaced by the MAX associated constant on this type
std::i64MINreplaced by the MIN associated constant on this type
std::i8MAXreplaced by the MAX associated constant on this type
std::i8MINreplaced by the MIN associated constant on this type
std::isizeMAXreplaced by the MAX associated constant on this type
std::isizeMINreplaced by the MIN associated constant on this type
std::sync::atomicAtomic::fetch_updaterenamed to try_update for consistency
std::u128MAXreplaced by the MAX associated constant on this type
std::u128MINreplaced by the MIN associated constant on this type
std::u16MAXreplaced by the MAX associated constant on this type
std::u16MINreplaced by the MIN associated constant on this type
std::u32MAXreplaced by the MAX associated constant on this type
std::u32MINreplaced by the MIN associated constant on this type
std::u64MAXreplaced by the MAX associated constant on this type
std::u64MINreplaced by the MIN associated constant on this type
std::u8MAXreplaced by the MAX associated constant on this type
std::u8MINreplaced by the MIN associated constant on this type
std::usizeMAXreplaced by the MAX associated constant on this type
std::usizeMINreplaced by the MIN associated constant on this type

Rust 1.82


Rust 1.82 版本頁
模組項目官方說明
std::panicPanicInfouse PanicHookInfo instead

Rust 1.59


Rust 1.59 版本頁
模組項目官方說明
std::arrayIntoIter::newuse IntoIterator::into_iter instead

Rust 1.52


Rust 1.52 版本頁
模組項目官方說明
std::allocLayoutErrName does not follow std convention, use LayoutError

Rust 1.51


Rust 1.51 版本頁
模組項目官方說明
std::sync::atomicspin_loop_hintuse hint::spin_loop instead

Rust 1.50


Rust 1.50 版本頁
模組項目官方說明
std::sync::atomicAtomic::compare_and_swapUse compare_exchange or compare_exchange_weak instead

Rust 1.42


Rust 1.42 版本頁
模組項目官方說明
std::errorError::descriptionuse the Display impl or to_string()

Rust 1.39


Rust 1.39 版本頁
模組項目官方說明
stdtry!use the ? operator instead
std::memuninitializeduse mem::MaybeUninit instead

Rust 1.38


Rust 1.38 版本頁
模組項目官方說明
std::syncONCE_INITthe Once::new() function is now preferred

Rust 1.37


Rust 1.37 版本頁
模組項目官方說明
std::os::unix::processCommandExt::before_execshould be unsafe, use pre_exec instead

Rust 1.34


Rust 1.34 版本頁
模組項目官方說明
std::sync::atomicATOMIC_BOOL_INITthe new function is now preferred
std::sync::atomicATOMIC_ISIZE_INITthe new function is now preferred
std::sync::atomicATOMIC_USIZE_INITthe new function is now preferred

Rust 1.33


Rust 1.33 版本頁
模組項目官方說明
stdstr::trim_leftsuperseded by trim_start
stdstr::trim_left_matchessuperseded by trim_start_matches
stdstr::trim_rightsuperseded by trim_end
stdstr::trim_right_matchessuperseded by trim_end_matches
std::errorError::causereplaced by Error::source, which can support downcasting
std::stringString::trim_leftsuperseded by trim_start
std::stringString::trim_left_matchessuperseded by trim_start_matches
std::stringString::trim_rightsuperseded by trim_end
std::stringString::trim_right_matchessuperseded by trim_end_matches

Rust 1.29


Rust 1.29 版本頁
模組項目官方說明
stdstr::slice_mut_uncheckeduse get_unchecked_mut(begin..end) instead
stdstr::slice_uncheckeduse get_unchecked(begin..end) instead
std::stringString::slice_mut_uncheckeduse get_unchecked_mut(begin..end) instead
std::stringString::slice_uncheckeduse get_unchecked(begin..end) instead

Rust 1.26


Rust 1.26 版本頁
模組項目官方說明
std::asciiAsciiExtuse inherent methods instead
std::asciiAsciiExt::eq_ignore_ascii_caseuse inherent methods instead
std::asciiAsciiExt::is_asciiuse inherent methods instead
std::asciiAsciiExt::make_ascii_lowercaseuse inherent methods instead
std::asciiAsciiExt::make_ascii_uppercaseuse inherent methods instead
std::asciiAsciiExt::Owneduse inherent methods instead
std::asciiAsciiExt::to_ascii_lowercaseuse inherent methods instead
std::asciiAsciiExt::to_ascii_uppercaseuse inherent methods instead

Rust 1.24


Rust 1.24 版本頁
模組項目官方說明
std::fmtFormatter::flagsuse the sign_plus, sign_minus, alternate, or sign_aware_zero_pad methods instead

Rust 1.16


Rust 1.16 版本頁
模組項目官方說明
std::netTcpListener::only_v6this option can only be set before the socket is bound
std::netTcpListener::set_only_v6this option can only be set before the socket is bound

Rust 1.13


Rust 1.13 版本頁
模組項目官方說明
std::hashSipHasheruse std::hash::DefaultHasher instead
std::hashSipHasher::newuse std::hash::DefaultHasher instead
std::hashSipHasher::new_with_keysuse std::hash::DefaultHasher instead

Rust 1.10


Rust 1.10 版本頁
模組項目官方說明
stdf32::abs_subyou probably meant (self - other).abs(): this operation is (self - other).max(0.0) except that abs_sub also propagates NaNs (also known as fdimf in C). If you truly need the positive difference, consider using that expression or the C function fdimf, depending on how you wish to handle NaN (please consider filing an issue describing your use-case too).
stdf64::abs_subyou probably meant (self - other).abs(): this operation is (self - other).max(0.0) except that abs_sub also propagates NaNs (also known as fdim in C). If you truly need the positive difference, consider using that expression or the C function fdim, depending on how you wish to handle NaN (please consider filing an issue describing your use-case too).

Rust 1.8


Rust 1.8 版本頁
模組項目官方說明
std::os::darwin::fsMetadataExt::as_raw_statdeprecated in favor of the accessor methods of this trait
std::os::linux::fsMetadataExt::as_raw_statother methods of this trait are now preferred
std::os::linux::rawblkcnt_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawblksize_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawdev_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawino_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawmode_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawnlink_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawoff_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawpthread_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawstatthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::linux::rawtime_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawblkcnt_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawblksize_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawdev_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawgid_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawino_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawmode_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawnlink_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawoff_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawpid_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawpthread_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawtime_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions
std::os::unix::rawuid_tthese type aliases are no longer supported by the standard library, the libc crate on crates.io should be used instead for the correct definitions

Rust 1.6


Rust 1.6 版本頁
模組項目官方說明
std::syncCondvar::wait_timeout_msreplaced by std::sync::Condvar::wait_timeout
std::sync::poisonCondvar::wait_timeout_msreplaced by std::sync::Condvar::wait_timeout
std::threadpark_timeout_msreplaced by std::thread::park_timeout
std::threadsleep_msreplaced by std::thread::sleep

Rust 1.4


Rust 1.4 版本頁
模組項目官方說明
stdstr::lines_anyuse lines() instead now
std::strLinesAnyuse lines()/Lines instead now
std::stringString::lines_anyuse lines() instead now

Rust 1.3


Rust 1.3 版本頁
模組項目官方說明
stdslice::connectrenamed to join
std::bstrByteStr::connectrenamed to join
std::bstrByteString::connectrenamed to join
std::ioIoSlice::connectrenamed to join
std::ioIoSliceMut::connectrenamed to join
std::vecVec::connectrenamed to join

Rust 1.2


Rust 1.2 版本頁
模組項目官方說明
std::memmin_align_ofuse align_of instead
std::memmin_align_of_valuse align_of_val instead

Rust 1.1


Rust 1.1 版本頁
模組項目官方說明
std::fssoft_linkreplaced with std::os::unix::fs::symlink and std::os::windows::fs::{symlink_file, symlink_dir}

資料來源