棄用 API
最後更新
依「從哪個版本開始棄用」列出標準庫中所有標記為
#[deprecated] 的穩定 API;棄用的 API 仍可編譯(會出現警告),但官方建議改用說明中的替代做法,本書範例一律不使用。棄用版本取自官方文件標示的「Deprecated since」;尚未決定版本(
TBD,未來才會棄用)的 API 不列入。Rust 1.99
Rust 1.99 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | i128::max_value | replaced by the MAX associated constant on this type |
std | i128::min_value | replaced by the MIN associated constant on this type |
std | i16::max_value | replaced by the MAX associated constant on this type |
std | i16::min_value | replaced by the MIN associated constant on this type |
std | i32::max_value | replaced by the MAX associated constant on this type |
std | i32::min_value | replaced by the MIN associated constant on this type |
std | i64::max_value | replaced by the MAX associated constant on this type |
std | i64::min_value | replaced by the MIN associated constant on this type |
std | i8::max_value | replaced by the MAX associated constant on this type |
std | i8::min_value | replaced by the MIN associated constant on this type |
std | isize::max_value | replaced by the MAX associated constant on this type |
std | isize::min_value | replaced by the MIN associated constant on this type |
std | u128::max_value | replaced by the MAX associated constant on this type |
std | u128::min_value | replaced by the MIN associated constant on this type |
std | u16::max_value | replaced by the MAX associated constant on this type |
std | u16::min_value | replaced by the MIN associated constant on this type |
std | u32::max_value | replaced by the MAX associated constant on this type |
std | u32::min_value | replaced by the MIN associated constant on this type |
std | u64::max_value | replaced by the MAX associated constant on this type |
std | u64::min_value | replaced by the MIN associated constant on this type |
std | u8::max_value | replaced by the MAX associated constant on this type |
std | u8::min_value | replaced by the MIN associated constant on this type |
std | usize::max_value | replaced by the MAX associated constant on this type |
std | usize::min_value | replaced by the MIN associated constant on this type |
std::f32 | DIGITS | replaced by the DIGITS associated constant on f32 |
std::f32 | EPSILON | replaced by the EPSILON associated constant on f32 |
std::f32 | INFINITY | replaced by the INFINITY associated constant on f32 |
std::f32 | MANTISSA_DIGITS | replaced by the MANTISSA_DIGITS associated constant on f32 |
std::f32 | MAX | replaced by the MAX associated constant on f32 |
std::f32 | MAX_10_EXP | replaced by the MAX_10_EXP associated constant on f32 |
std::f32 | MAX_EXP | replaced by the MAX_EXP associated constant on f32 |
std::f32 | MIN | replaced by the MIN associated constant on f32 |
std::f32 | MIN_10_EXP | replaced by the MIN_10_EXP associated constant on f32 |
std::f32 | MIN_EXP | replaced by the MIN_EXP associated constant on f32 |
std::f32 | MIN_POSITIVE | replaced by the MIN_POSITIVE associated constant on f32 |
std::f32 | NAN | replaced by the NAN associated constant on f32 |
std::f32 | NEG_INFINITY | replaced by the NEG_INFINITY associated constant on f32 |
std::f32 | RADIX | replaced by the RADIX associated constant on f32 |
std::f64 | DIGITS | replaced by the DIGITS associated constant on f64 |
std::f64 | EPSILON | replaced by the EPSILON associated constant on f64 |
std::f64 | INFINITY | replaced by the INFINITY associated constant on f64 |
std::f64 | MANTISSA_DIGITS | replaced by the MANTISSA_DIGITS associated constant on f64 |
std::f64 | MAX | replaced by the MAX associated constant on f64 |
std::f64 | MAX_10_EXP | replaced by the MAX_10_EXP associated constant on f64 |
std::f64 | MAX_EXP | replaced by the MAX_EXP associated constant on f64 |
std::f64 | MIN | replaced by the MIN associated constant on f64 |
std::f64 | MIN_10_EXP | replaced by the MIN_10_EXP associated constant on f64 |
std::f64 | MIN_EXP | replaced by the MIN_EXP associated constant on f64 |
std::f64 | MIN_POSITIVE | replaced by the MIN_POSITIVE associated constant on f64 |
std::f64 | NAN | replaced by the NAN associated constant on f64 |
std::f64 | NEG_INFINITY | replaced by the NEG_INFINITY associated constant on f64 |
std::f64 | RADIX | replaced by the RADIX associated constant on f64 |
std::i128 | MAX | replaced by the MAX associated constant on this type |
std::i128 | MIN | replaced by the MIN associated constant on this type |
std::i16 | MAX | replaced by the MAX associated constant on this type |
std::i16 | MIN | replaced by the MIN associated constant on this type |
std::i32 | MAX | replaced by the MAX associated constant on this type |
std::i32 | MIN | replaced by the MIN associated constant on this type |
std::i64 | MAX | replaced by the MAX associated constant on this type |
std::i64 | MIN | replaced by the MIN associated constant on this type |
std::i8 | MAX | replaced by the MAX associated constant on this type |
std::i8 | MIN | replaced by the MIN associated constant on this type |
std::isize | MAX | replaced by the MAX associated constant on this type |
std::isize | MIN | replaced by the MIN associated constant on this type |
std::sync::atomic | Atomic::fetch_update | renamed to try_update for consistency |
std::u128 | MAX | replaced by the MAX associated constant on this type |
std::u128 | MIN | replaced by the MIN associated constant on this type |
std::u16 | MAX | replaced by the MAX associated constant on this type |
std::u16 | MIN | replaced by the MIN associated constant on this type |
std::u32 | MAX | replaced by the MAX associated constant on this type |
std::u32 | MIN | replaced by the MIN associated constant on this type |
std::u64 | MAX | replaced by the MAX associated constant on this type |
std::u64 | MIN | replaced by the MIN associated constant on this type |
std::u8 | MAX | replaced by the MAX associated constant on this type |
std::u8 | MIN | replaced by the MIN associated constant on this type |
std::usize | MAX | replaced by the MAX associated constant on this type |
std::usize | MIN | replaced by the MIN associated constant on this type |
Rust 1.82
Rust 1.82 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::panic | PanicInfo | use PanicHookInfo instead |
Rust 1.59
Rust 1.59 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::array | IntoIter::new | use IntoIterator::into_iter instead |
Rust 1.52
Rust 1.52 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::alloc | LayoutErr | Name does not follow std convention, use LayoutError |
Rust 1.51
Rust 1.51 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::sync::atomic | spin_loop_hint | use hint::spin_loop instead |
Rust 1.50
Rust 1.50 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::sync::atomic | Atomic::compare_and_swap | Use compare_exchange or compare_exchange_weak instead |
Rust 1.42
Rust 1.42 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::error | Error::description | use the Display impl or to_string() |
Rust 1.39
Rust 1.39 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | try! | use the ? operator instead |
std::mem | uninitialized | use mem::MaybeUninit instead |
Rust 1.38
Rust 1.38 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::sync | ONCE_INIT | the Once::new() function is now preferred |
Rust 1.37
Rust 1.37 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::os::unix::process | CommandExt::before_exec | should be unsafe, use pre_exec instead |
Rust 1.34
Rust 1.34 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::sync::atomic | ATOMIC_BOOL_INIT | the new function is now preferred |
std::sync::atomic | ATOMIC_ISIZE_INIT | the new function is now preferred |
std::sync::atomic | ATOMIC_USIZE_INIT | the new function is now preferred |
Rust 1.33
Rust 1.33 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | str::trim_left | superseded by trim_start |
std | str::trim_left_matches | superseded by trim_start_matches |
std | str::trim_right | superseded by trim_end |
std | str::trim_right_matches | superseded by trim_end_matches |
std::error | Error::cause | replaced by Error::source, which can support downcasting |
std::string | String::trim_left | superseded by trim_start |
std::string | String::trim_left_matches | superseded by trim_start_matches |
std::string | String::trim_right | superseded by trim_end |
std::string | String::trim_right_matches | superseded by trim_end_matches |
Rust 1.29
Rust 1.29 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | str::slice_mut_unchecked | use get_unchecked_mut(begin..end) instead |
std | str::slice_unchecked | use get_unchecked(begin..end) instead |
std::string | String::slice_mut_unchecked | use get_unchecked_mut(begin..end) instead |
std::string | String::slice_unchecked | use get_unchecked(begin..end) instead |
Rust 1.26
Rust 1.26 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::ascii | AsciiExt | use inherent methods instead |
std::ascii | AsciiExt::eq_ignore_ascii_case | use inherent methods instead |
std::ascii | AsciiExt::is_ascii | use inherent methods instead |
std::ascii | AsciiExt::make_ascii_lowercase | use inherent methods instead |
std::ascii | AsciiExt::make_ascii_uppercase | use inherent methods instead |
std::ascii | AsciiExt::Owned | use inherent methods instead |
std::ascii | AsciiExt::to_ascii_lowercase | use inherent methods instead |
std::ascii | AsciiExt::to_ascii_uppercase | use inherent methods instead |
Rust 1.24
Rust 1.24 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::fmt | Formatter::flags | use the sign_plus, sign_minus, alternate, or sign_aware_zero_pad methods instead |
Rust 1.16
Rust 1.16 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::net | TcpListener::only_v6 | this option can only be set before the socket is bound |
std::net | TcpListener::set_only_v6 | this option can only be set before the socket is bound |
Rust 1.13
Rust 1.13 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::hash | SipHasher | use std::hash::DefaultHasher instead |
std::hash | SipHasher::new | use std::hash::DefaultHasher instead |
std::hash | SipHasher::new_with_keys | use std::hash::DefaultHasher instead |
Rust 1.10
Rust 1.10 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | f32::abs_sub | you 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). |
std | f64::abs_sub | you 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::fs | MetadataExt::as_raw_stat | deprecated in favor of the accessor methods of this trait |
std::os::linux::fs | MetadataExt::as_raw_stat | other methods of this trait are now preferred |
std::os::linux::raw | blkcnt_t | these 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::raw | blksize_t | these 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::raw | dev_t | these 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::raw | ino_t | these 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::raw | mode_t | these 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::raw | nlink_t | these 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::raw | off_t | these 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::raw | pthread_t | these 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::raw | stat | these 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::raw | time_t | these 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::raw | blkcnt_t | these 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::raw | blksize_t | these 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::raw | dev_t | these 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::raw | gid_t | these 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::raw | ino_t | these 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::raw | mode_t | these 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::raw | nlink_t | these 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::raw | off_t | these 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::raw | pid_t | these 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::raw | pthread_t | these 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::raw | time_t | these 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::raw | uid_t | these 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::sync | Condvar::wait_timeout_ms | replaced by std::sync::Condvar::wait_timeout |
std::sync::poison | Condvar::wait_timeout_ms | replaced by std::sync::Condvar::wait_timeout |
std::thread | park_timeout_ms | replaced by std::thread::park_timeout |
std::thread | sleep_ms | replaced by std::thread::sleep |
Rust 1.4
Rust 1.4 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | str::lines_any | use lines() instead now |
std::str | LinesAny | use lines()/Lines instead now |
std::string | String::lines_any | use lines() instead now |
Rust 1.3
Rust 1.3 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std | slice::connect | renamed to join |
std::bstr | ByteStr::connect | renamed to join |
std::bstr | ByteString::connect | renamed to join |
std::io | IoSlice::connect | renamed to join |
std::io | IoSliceMut::connect | renamed to join |
std::vec | Vec::connect | renamed to join |
Rust 1.2
Rust 1.2 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::mem | min_align_of | use align_of instead |
std::mem | min_align_of_val | use align_of_val instead |
Rust 1.1
Rust 1.1 版本頁
| 模組 | 項目 | 官方說明 |
|---|---|---|
std::fs | soft_link | replaced with std::os::unix::fs::symlink and std::os::windows::fs::{symlink_file, symlink_dir} |
資料來源
- Rust 標準庫文件(各 API 的 Deprecated since 標示,取自 rust-docs 元件 1.100.0)
- Rust 發版紀錄(RELEASES.md)