Trait std::convert::From

1.0.0 · source ·
pub trait From<T>: Sized {
    // Required method
    fn from(value: T) -> Self;
}
Expand description

用于在消耗输入值的同时进行值到值的转换。它是 Into 的倒数。

与标准 Into 相比,人们应该总是更喜欢实现 From,因为由于标准库中的全面实现,实现 From 会自动为 Into 提供一个 Into 的实现。

仅当针对 Rust 1.41 之前的版本并将其转换为当前 crate 以外的类型时,才实现 Into。 由于 Rust 的孤儿规则,From 在早期版本中无法进行这些类型的转换。 有关更多详细信息,请参见 Into

在泛型函数上指定 trait bounds 时,优先使用 Into。 这样,直接实现 Into 的类型也可以用作参数。

From 在执行错误处理时也非常有用。当创建一个能够失败的函数时,返回类型通常为 Result<T, E> 形式。 From trait 通过允许函数返回封装了多种错误类型的单个错误类型,简化了错误处理。有关更多详细信息,请参见示例部分和这本

注意:此 trait 一定不能失败From trait 旨在实现完美转换。 如果转换失败或不完美,请使用 TryFrom

泛型实现

  • From<T> for U 意味着 Into<U> for T
  • From 是反射的,这意味着 From<T> for T 被实现

Examples

String 实现 From<&str>

&str 到字符串的显式转换如下:

let string = "hello".to_string();
let other_string = String::from("hello");

assert_eq!(string, other_string);
Run

在执行错误处理时,通常对于您自己的错误类型实现 From 很有用。 通过将底层错误类型转换为封装底层错误类型的自定义错误类型,我们可以返回单个错误类型,而不会丢失有关底层原因的信息。 ‘?’ 运算符通过调用 Into<CliError>::into 自动将底层错误类型转换为我们的自定义错误类型,该 Into<CliError>::into 是在实现 From 时自动提供的。 然后,编译器会推断应使用 Into 的哪种实现。

use std::fs;
use std::io;
use std::num;

enum CliError {
    IoError(io::Error),
    ParseError(num::ParseIntError),
}

impl From<io::Error> for CliError {
    fn from(error: io::Error) -> Self {
        CliError::IoError(error)
    }
}

impl From<num::ParseIntError> for CliError {
    fn from(error: num::ParseIntError) -> Self {
        CliError::ParseError(error)
    }
}

fn open_and_parse_file(file_name: &str) -> Result<i32, CliError> {
    let mut contents = fs::read_to_string(&file_name)?;
    let num: i32 = contents.trim().parse()?;
    Ok(num)
}
Run

Required Methods§

source

fn from(value: T) -> Self

从输入类型转换为此类型。

Implementors§

1.17.0 · source§

impl From<&str> for Box<str, Global>

1.6.0 · source§

impl From<&str> for Box<dyn Error + 'static, Global>

1.21.0 · source§

impl From<&str> for Rc<str>

source§

impl From<&str> for String

1.21.0 · source§

impl From<&str> for Arc<str>

source§

impl From<&str> for Vec<u8, Global>

1.17.0 · source§

impl From<&CStr> for Box<CStr, Global>

1.7.0 · source§

impl From<&CStr> for CString

1.24.0 · source§

impl From<&CStr> for Rc<CStr>

1.24.0 · source§

impl From<&CStr> for Arc<CStr>

1.17.0 · source§

impl From<&OsStr> for Box<OsStr>

1.24.0 · source§

impl From<&OsStr> for Rc<OsStr>

1.24.0 · source§

impl From<&OsStr> for Arc<OsStr>

1.17.0 · source§

impl From<&Path> for Box<Path>

1.24.0 · source§

impl From<&Path> for Rc<Path>

1.24.0 · source§

impl From<&Path> for Arc<Path>

1.35.0 · source§

impl From<&String> for String

1.44.0 · source§

impl From<&mut str> for String

1.45.0 · source§

impl From<Cow<'_, str>> for Box<str, Global>

1.45.0 · source§

impl From<Cow<'_, CStr>> for Box<CStr, Global>

1.45.0 · source§

impl From<Cow<'_, OsStr>> for Box<OsStr>

1.45.0 · source§

impl From<Cow<'_, Path>> for Box<Path>

source§

impl From<TryReserveErrorKind> for TryReserveError

1.14.0 · source§

impl From<ErrorKind> for Error

旨在用于未暴露给用户的错误,因为分配到堆上 (通过 Error::new 进行常规构建) 的代价太高了。

1.36.0 · source§

impl From<Infallible> for TryFromSliceError

1.34.0 · source§

impl From<Infallible> for TryFromIntError

1.68.0 · source§

impl From<bool> for f32

1.68.0 · source§

impl From<bool> for f64

1.28.0 · source§

impl From<bool> for i8

1.28.0 · source§

impl From<bool> for i16

1.28.0 · source§

impl From<bool> for i32

1.28.0 · source§

impl From<bool> for i64

1.28.0 · source§

impl From<bool> for i128

1.28.0 · source§

impl From<bool> for isize

1.28.0 · source§

impl From<bool> for u8

1.28.0 · source§

impl From<bool> for u16

1.28.0 · source§

impl From<bool> for u32

1.28.0 · source§

impl From<bool> for u64

1.28.0 · source§

impl From<bool> for u128

1.28.0 · source§

impl From<bool> for usize

1.24.0 · source§

impl From<bool> for AtomicBool

1.13.0 · source§

impl From<char> for u32

1.51.0 · source§

impl From<char> for u64

1.51.0 · source§

impl From<char> for u128

1.46.0 · source§

impl From<char> for String

1.6.0 · source§

impl From<f32> for f64

1.6.0 · source§

impl From<i8> for f32

1.6.0 · source§

impl From<i8> for f64

1.5.0 · source§

impl From<i8> for i16

1.5.0 · source§

impl From<i8> for i32

1.5.0 · source§

impl From<i8> for i64

1.26.0 · source§

impl From<i8> for i128

1.5.0 · source§

impl From<i8> for isize

1.34.0 · source§

impl From<i8> for AtomicI8

1.6.0 · source§

impl From<i16> for f32

1.6.0 · source§

impl From<i16> for f64

1.5.0 · source§

impl From<i16> for i32

1.5.0 · source§

impl From<i16> for i64

1.26.0 · source§

impl From<i16> for i128

1.26.0 · source§

impl From<i16> for isize

1.34.0 · source§

impl From<i16> for AtomicI16

1.6.0 · source§

impl From<i32> for f64

1.5.0 · source§

impl From<i32> for i64

1.26.0 · source§

impl From<i32> for i128

1.34.0 · source§

impl From<i32> for AtomicI32

1.26.0 · source§

impl From<i64> for i128

1.34.0 · source§

impl From<i64> for AtomicI64

1.23.0 · source§

impl From<isize> for AtomicIsize

1.34.0 · source§

impl From<!> for Infallible

source§

impl From<!> for TryFromIntError

1.13.0 · source§

impl From<u8> for char

将 0x00..=0xFF 中的字节映射到 char,该 char 的代码点具有相同的值,即 U+0000..=U+00FF。

Unicode 的设计使其可以使用 IANA 称为 ISO-8859-1 的字符编码有效地解码字节。 此编码与 ASCII 兼容。

请注意,这与 ISO/IEC 8859-1 又名不同 ISO 8859-1 (连字符少一个),它留下了一些 “blanks” 字节值,这些值未分配给任何字符。 ISO-8859-1 (属于 IANA) 将它们分配给 C0 和 C1 控制代码。

请注意,这也与 Windows-1252 也不同 代码页 1252,它是 ISO/IEC 8859-1 的超集,它为标点符号和各种拉丁字符分配了一些 (不是全部) 空格。

为了进一步混淆,在 Web 上 asciiiso-8859-1windows-1252 都是 Windows-1252 超集的别名,该超集用相应的 C0 和 C1 控制代码填充了其余的空白。

1.6.0 · source§

impl From<u8> for f32

1.6.0 · source§

impl From<u8> for f64

1.5.0 · source§

impl From<u8> for i16

1.5.0 · source§

impl From<u8> for i32

1.5.0 · source§

impl From<u8> for i64

1.26.0 · source§

impl From<u8> for i128

1.26.0 · source§

impl From<u8> for isize

1.5.0 · source§

impl From<u8> for u16

1.5.0 · source§

impl From<u8> for u32

1.5.0 · source§

impl From<u8> for u64

1.26.0 · source§

impl From<u8> for u128

1.5.0 · source§

impl From<u8> for usize

1.61.0 · source§

impl From<u8> for ExitCode

1.34.0 · source§

impl From<u8> for AtomicU8

1.6.0 · source§

impl From<u16> for f32

1.6.0 · source§

impl From<u16> for f64

1.5.0 · source§

impl From<u16> for i32

1.5.0 · source§

impl From<u16> for i64

1.26.0 · source§

impl From<u16> for i128

1.5.0 · source§

impl From<u16> for u32

1.5.0 · source§

impl From<u16> for u64

1.26.0 · source§

impl From<u16> for u128

1.26.0 · source§

impl From<u16> for usize

1.34.0 · source§

impl From<u16> for AtomicU16

1.6.0 · source§

impl From<u32> for f64

1.5.0 · source§

impl From<u32> for i64

1.26.0 · source§

impl From<u32> for i128

1.5.0 · source§

impl From<u32> for u64

1.26.0 · source§

impl From<u32> for u128

1.1.0 · source§

impl From<u32> for Ipv4Addr

1.34.0 · source§

impl From<u32> for AtomicU32

1.26.0 · source§

impl From<u64> for i128

1.26.0 · source§

impl From<u64> for u128

1.34.0 · source§

impl From<u64> for AtomicU64

1.26.0 · source§

impl From<u128> for Ipv6Addr

1.23.0 · source§

impl From<usize> for AtomicUsize

source§

impl From<__m128> for Simd<f32, 4>

source§

impl From<__m128d> for Simd<f64, 2>

source§

impl From<__m128i> for Simd<i8, 16>

source§

impl From<__m128i> for Simd<i16, 8>

source§

impl From<__m128i> for Simd<i32, 4>

source§

impl From<__m128i> for Simd<i64, 2>

source§

impl From<__m128i> for Simd<isize, 2>

source§

impl From<__m128i> for Simd<u8, 16>

source§

impl From<__m128i> for Simd<u16, 8>

source§

impl From<__m128i> for Simd<u32, 4>

source§

impl From<__m128i> for Simd<u64, 2>

source§

impl From<__m128i> for Simd<usize, 2>

source§

impl From<__m256> for Simd<f32, 8>

source§

impl From<__m256d> for Simd<f64, 4>

source§

impl From<__m256i> for Simd<i8, 32>

source§

impl From<__m256i> for Simd<i16, 16>

source§

impl From<__m256i> for Simd<i32, 8>

source§

impl From<__m256i> for Simd<i64, 4>

source§

impl From<__m256i> for Simd<isize, 4>

source§

impl From<__m256i> for Simd<u8, 32>

source§

impl From<__m256i> for Simd<u16, 16>

source§

impl From<__m256i> for Simd<u32, 8>

source§

impl From<__m256i> for Simd<u64, 4>

source§

impl From<__m256i> for Simd<usize, 4>

source§

impl From<__m512> for Simd<f32, 16>

source§

impl From<__m512d> for Simd<f64, 8>

source§

impl From<__m512i> for Simd<i8, 64>

source§

impl From<__m512i> for Simd<i16, 32>

source§

impl From<__m512i> for Simd<i32, 16>

source§

impl From<__m512i> for Simd<i64, 8>

source§

impl From<__m512i> for Simd<isize, 8>

source§

impl From<__m512i> for Simd<u8, 64>

source§

impl From<__m512i> for Simd<u16, 32>

source§

impl From<__m512i> for Simd<u32, 16>

source§

impl From<__m512i> for Simd<u64, 8>

source§

impl From<__m512i> for Simd<usize, 8>

source§

impl From<LayoutError> for TryReserveErrorKind

1.18.0 · source§

impl From<Box<str, Global>> for String

1.18.0 · source§

impl From<Box<CStr, Global>> for CString

1.18.0 · source§

impl From<Box<OsStr, Global>> for OsString

1.18.0 · source§

impl From<Box<Path, Global>> for PathBuf

1.20.0 · source§

impl From<CString> for Box<CStr, Global>

1.24.0 · source§

impl From<CString> for Rc<CStr>

1.24.0 · source§

impl From<CString> for Arc<CStr>

1.7.0 · source§

impl From<CString> for Vec<u8, Global>

source§

impl From<NulError> for Error

1.20.0 · source§

impl From<OsString> for Box<OsStr>

source§

impl From<OsString> for PathBuf

1.24.0 · source§

impl From<OsString> for Rc<OsStr>

1.24.0 · source§

impl From<OsString> for Arc<OsStr>

1.63.0 · source§

impl From<File> for OwnedFd

1.63.0 · source§

impl From<File> for OwnedHandle

Available on Windows only.
1.20.0 · source§

impl From<File> for Stdio

1.16.0 · source§

impl From<Ipv4Addr> for IpAddr

1.1.0 · source§

impl From<Ipv4Addr> for u32

1.16.0 · source§

impl From<Ipv6Addr> for IpAddr

1.26.0 · source§

impl From<Ipv6Addr> for u128

1.16.0 · source§

impl From<SocketAddrV4> for SocketAddr

1.16.0 · source§

impl From<SocketAddrV6> for SocketAddr

1.63.0 · source§

impl From<TcpListener> for OwnedFd

1.63.0 · source§

impl From<TcpListener> for OwnedSocket

Available on Windows only.
1.63.0 · source§

impl From<TcpStream> for OwnedFd

1.63.0 · source§

impl From<TcpStream> for OwnedSocket

Available on Windows only.
1.63.0 · source§

impl From<UdpSocket> for OwnedFd

1.63.0 · source§

impl From<UdpSocket> for OwnedSocket

Available on Windows only.
1.31.0 · source§

impl From<NonZeroI8> for i8

1.41.0 · source§

impl From<NonZeroI8> for NonZeroI16

1.41.0 · source§

impl From<NonZeroI8> for NonZeroI32

1.41.0 · source§

impl From<NonZeroI8> for NonZeroI64

1.41.0 · source§

impl From<NonZeroI8> for NonZeroI128

1.41.0 · source§

impl From<NonZeroI8> for NonZeroIsize

1.31.0 · source§

impl From<NonZeroI16> for i16

1.41.0 · source§

impl From<NonZeroI16> for NonZeroI32

1.41.0 · source§

impl From<NonZeroI16> for NonZeroI64

1.41.0 · source§

impl From<NonZeroI16> for NonZeroI128

1.41.0 · source§

impl From<NonZeroI16> for NonZeroIsize

1.31.0 · source§

impl From<NonZeroI32> for i32

1.41.0 · source§

impl From<NonZeroI32> for NonZeroI64

1.41.0 · source§

impl From<NonZeroI32> for NonZeroI128

1.31.0 · source§

impl From<NonZeroI64> for i64

1.41.0 · source§

impl From<NonZeroI64> for NonZeroI128

1.31.0 · source§

impl From<NonZeroI128> for i128

1.31.0 · source§

impl From<NonZeroIsize> for isize

1.31.0 · source§

impl From<NonZeroU8> for u8

1.41.0 · source§

impl From<NonZeroU8> for NonZeroI16

1.41.0 · source§

impl From<NonZeroU8> for NonZeroI32

1.41.0 · source§

impl From<NonZeroU8> for NonZeroI64

1.41.0 · source§

impl From<NonZeroU8> for NonZeroI128

1.41.0 · source§

impl From<NonZeroU8> for NonZeroIsize

1.41.0 · source§

impl From<NonZeroU8> for NonZeroU16

1.41.0 · source§

impl From<NonZeroU8> for NonZeroU32

1.41.0 · source§

impl From<NonZeroU8> for NonZeroU64

1.41.0 · source§

impl From<NonZeroU8> for NonZeroU128

1.41.0 · source§

impl From<NonZeroU8> for NonZeroUsize

1.31.0 · source§

impl From<NonZeroU16> for u16

1.41.0 · source§

impl From<NonZeroU16> for NonZeroI32

1.41.0 · source§

impl From<NonZeroU16> for NonZeroI64

1.41.0 · source§

impl From<NonZeroU16> for NonZeroI128

1.41.0 · source§

impl From<NonZeroU16> for NonZeroU32

1.41.0 · source§

impl From<NonZeroU16> for NonZeroU64

1.41.0 · source§

impl From<NonZeroU16> for NonZeroU128

1.41.0 · source§

impl From<NonZeroU16> for NonZeroUsize

1.31.0 · source§

impl From<NonZeroU32> for u32

1.41.0 · source§

impl From<NonZeroU32> for NonZeroI64

1.41.0 · source§

impl From<NonZeroU32> for NonZeroI128

1.41.0 · source§

impl From<NonZeroU32> for NonZeroU64

1.41.0 · source§

impl From<NonZeroU32> for NonZeroU128

1.31.0 · source§

impl From<NonZeroU64> for u64

1.41.0 · source§

impl From<NonZeroU64> for NonZeroI128

1.41.0 · source§

impl From<NonZeroU64> for NonZeroU128

1.31.0 · source§

impl From<NonZeroU128> for u128

1.31.0 · source§

impl From<NonZeroUsize> for usize

1.63.0 · source§

impl From<OwnedFd> for File

1.63.0 · source§

impl From<OwnedFd> for TcpListener

1.63.0 · source§

impl From<OwnedFd> for TcpStream

1.63.0 · source§

impl From<OwnedFd> for UdpSocket

source§

impl From<OwnedFd> for PidFd

Available on Linux only.
1.63.0 · source§

impl From<OwnedFd> for UnixDatagram

Available on Unix only.
1.63.0 · source§

impl From<OwnedFd> for UnixListener

Available on Unix only.
1.63.0 · source§

impl From<OwnedFd> for UnixStream

Available on Unix only.
1.63.0 · source§

impl From<OwnedFd> for Stdio

Available on Unix only.
source§

impl From<PidFd> for OwnedFd

Available on Linux only.
1.63.0 · source§

impl From<UnixDatagram> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<UnixListener> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<UnixStream> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<OwnedHandle> for File

Available on Windows only.
1.63.0 · source§

impl From<OwnedHandle> for Stdio

Available on Windows only.
1.63.0 · source§

impl From<OwnedSocket> for TcpListener

Available on Windows only.
1.63.0 · source§

impl From<OwnedSocket> for TcpStream

Available on Windows only.
1.63.0 · source§

impl From<OwnedSocket> for UdpSocket

Available on Windows only.
1.20.0 · source§

impl From<PathBuf> for Box<Path>

1.14.0 · source§

impl From<PathBuf> for OsString

1.24.0 · source§

impl From<PathBuf> for Rc<Path>

1.24.0 · source§

impl From<PathBuf> for Arc<Path>

1.63.0 · source§

impl From<Child> for OwnedHandle

Available on Windows only.
1.63.0 · source§

impl From<ChildStderr> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<ChildStderr> for OwnedHandle

Available on Windows only.
1.20.0 · source§

impl From<ChildStderr> for Stdio

1.63.0 · source§

impl From<ChildStdin> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<ChildStdin> for OwnedHandle

Available on Windows only.
1.20.0 · source§

impl From<ChildStdin> for Stdio

1.63.0 · source§

impl From<ChildStdout> for OwnedFd

Available on Unix only.
1.63.0 · source§

impl From<ChildStdout> for OwnedHandle

Available on Windows only.
1.20.0 · source§

impl From<ChildStdout> for Stdio

source§

impl From<Alignment> for usize

source§

impl From<Alignment> for NonZeroUsize

1.62.0 · source§

impl From<Rc<str>> for Rc<[u8]>

source§

impl From<Simd<f32, 4>> for __m128

source§

impl From<Simd<f32, 8>> for __m256

source§

impl From<Simd<f32, 16>> for __m512

source§

impl From<Simd<f64, 2>> for __m128d

source§

impl From<Simd<f64, 4>> for __m256d

source§

impl From<Simd<f64, 8>> for __m512d

source§

impl From<Simd<i8, 16>> for __m128i

source§

impl From<Simd<i8, 32>> for __m256i

source§

impl From<Simd<i8, 64>> for __m512i

source§

impl From<Simd<i16, 8>> for __m128i

source§

impl From<Simd<i16, 16>> for __m256i

source§

impl From<Simd<i16, 32>> for __m512i

source§

impl From<Simd<i32, 4>> for __m128i

source§

impl From<Simd<i32, 8>> for __m256i

source§

impl From<Simd<i32, 16>> for __m512i

source§

impl From<Simd<i64, 2>> for __m128i

source§

impl From<Simd<i64, 4>> for __m256i

source§

impl From<Simd<i64, 8>> for __m512i

source§

impl From<Simd<isize, 2>> for __m128i

source§

impl From<Simd<isize, 4>> for __m256i

source§

impl From<Simd<isize, 8>> for __m512i

source§

impl From<Simd<u8, 16>> for __m128i

source§

impl From<Simd<u8, 32>> for __m256i

source§

impl From<Simd<u8, 64>> for __m512i

source§

impl From<Simd<u16, 8>> for __m128i

source§

impl From<Simd<u16, 16>> for __m256i

source§

impl From<Simd<u16, 32>> for __m512i

source§

impl From<Simd<u32, 4>> for __m128i

source§

impl From<Simd<u32, 8>> for __m256i

source§

impl From<Simd<u32, 16>> for __m512i

source§

impl From<Simd<u64, 2>> for __m128i

source§

impl From<Simd<u64, 4>> for __m256i

source§

impl From<Simd<u64, 8>> for __m512i

source§

impl From<Simd<usize, 2>> for __m128i

source§

impl From<Simd<usize, 4>> for __m256i

source§

impl From<Simd<usize, 8>> for __m512i

1.20.0 · source§

impl From<String> for Box<str, Global>

1.6.0 · source§

impl From<String> for Box<dyn Error + 'static, Global>

source§

impl From<String> for Box<dyn Error + Send + Sync + 'static, Global>

source§

impl From<String> for OsString

source§

impl From<String> for PathBuf

1.21.0 · source§

impl From<String> for Rc<str>

1.21.0 · source§

impl From<String> for Arc<str>

1.14.0 · source§

impl From<String> for Vec<u8, Global>

1.24.0 · source§

impl From<RecvError> for RecvTimeoutError

1.24.0 · source§

impl From<RecvError> for TryRecvError

1.62.0 · source§

impl From<Arc<str>> for Arc<[u8]>

1.43.0 · source§

impl From<Vec<NonZeroU8, Global>> for CString

1.17.0 · source§

impl From<[u8; 4]> for IpAddr

1.9.0 · source§

impl From<[u8; 4]> for Ipv4Addr

1.17.0 · source§

impl From<[u8; 16]> for IpAddr

1.9.0 · source§

impl From<[u8; 16]> for Ipv6Addr

1.17.0 · source§

impl From<[u16; 8]> for IpAddr

1.16.0 · source§

impl From<[u16; 8]> for Ipv6Addr

source§

impl<'a> From<&'a str> for Cow<'a, str>

1.28.0 · source§

impl<'a> From<&'a CStr> for Cow<'a, CStr>

1.28.0 · source§

impl<'a> From<&'a CString> for Cow<'a, CStr>

1.28.0 · source§

impl<'a> From<&'a OsStr> for Cow<'a, OsStr>

1.28.0 · source§

impl<'a> From<&'a OsString> for Cow<'a, OsStr>

1.6.0 · source§

impl<'a> From<&'a Path> for Cow<'a, Path>

1.28.0 · source§

impl<'a> From<&'a PathBuf> for Cow<'a, Path>

1.28.0 · source§

impl<'a> From<&'a String> for Cow<'a, str>

source§

impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a, Global>

1.22.0 · source§

impl<'a> From<Cow<'a, str>> for Box<dyn Error + 'static, Global>

1.14.0 · source§

impl<'a> From<Cow<'a, str>> for String

1.28.0 · source§

impl<'a> From<Cow<'a, CStr>> for CString

1.28.0 · source§

impl<'a> From<Cow<'a, OsStr>> for OsString

1.28.0 · source§

impl<'a> From<Cow<'a, Path>> for PathBuf

1.28.0 · source§

impl<'a> From<CString> for Cow<'a, CStr>

1.28.0 · source§

impl<'a> From<OsString> for Cow<'a, OsStr>

1.6.0 · source§

impl<'a> From<PathBuf> for Cow<'a, Path>

source§

impl<'a> From<String> for Cow<'a, str>

1.22.0 · source§

impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a, Global>

1.45.0 · source§

impl<'a, B> From<Cow<'a, B>> for Rc<B>where B: ToOwned + ?Sized, Rc<B>: From<&'a B> + From<<B as ToOwned>::Owned>,

1.45.0 · source§

impl<'a, B> From<Cow<'a, B>> for Arc<B>where B: ToOwned + ?Sized, Arc<B>: From<&'a B> + From<<B as ToOwned>::Owned>,

source§

impl<'a, E> From<E> for Box<dyn Error + 'a, Global>where E: Error + 'a,

source§

impl<'a, E> From<E> for Box<dyn Error + Send + Sync + 'a, Global>where E: Error + Send + Sync + 'a,

1.30.0 · source§

impl<'a, T> From<&'a Option<T>> for Option<&'a T>

1.8.0 · source§

impl<'a, T> From<&'a [T]> for Cow<'a, [T]>where T: Clone,

1.28.0 · source§

impl<'a, T> From<&'a Vec<T, Global>> for Cow<'a, [T]>where T: Clone,

1.30.0 · source§

impl<'a, T> From<&'a mut Option<T>> for Option<&'a mut T>

1.14.0 · source§

impl<'a, T> From<Cow<'a, [T]>> for Vec<T, Global>where [T]: ToOwned<Owned = Vec<T, Global>>,

1.8.0 · source§

impl<'a, T> From<Vec<T, Global>> for Cow<'a, [T]>where T: Clone,

source§

impl<'data> From<&'data mut [u8]> for BorrowedBuf<'data>

从完全初始化的切片创建一个新的 BorrowedBuf

source§

impl<'data> From<&'data mut [MaybeUninit<u8>]> for BorrowedBuf<'data>

从未初始化的缓冲区创建一个新的 BorrowedBuf

如果已知缓冲区的一部分已经初始化,则使用 set_init

1.19.0 · source§

impl<A> From<Box<str, A>> for Box<[u8], A>where A: Allocator,

source§

impl<E> From<E> for Report<E>where E: Error,

1.17.0 · source§

impl<I> From<(I, u16)> for SocketAddrwhere I: Into<IpAddr>,

1.56.0 · source§

impl<K, V, const N: usize> From<[(K, V); N]> for HashMap<K, V, RandomState>where K: Eq + Hash,

1.56.0 · source§

impl<K, V, const N: usize> From<[(K, V); N]> for BTreeMap<K, V, Global>where K: Ord,

1.17.0 · source§

impl<T> From<&[T]> for Box<[T], Global>where T: Clone,

1.21.0 · source§

impl<T> From<&[T]> for Rc<[T]>where T: Clone,

1.21.0 · source§

impl<T> From<&[T]> for Arc<[T]>where T: Clone,

source§

impl<T> From<&[T]> for Vec<T, Global>where T: Clone,

1.19.0 · source§

impl<T> From<&mut [T]> for Vec<T, Global>where T: Clone,

1.45.0 · source§

impl<T> From<Cow<'_, [T]>> for Box<[T], Global>where T: Clone,

1.71.0 · source§

impl<T> From<[T; 1]> for (T,)

1.71.0 · source§

impl<T> From<[T; 2]> for (T, T)

1.71.0 · source§

impl<T> From<[T; 3]> for (T, T, T)

1.71.0 · source§

impl<T> From<[T; 4]> for (T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 5]> for (T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 6]> for (T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 7]> for (T, T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 8]> for (T, T, T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 9]> for (T, T, T, T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 10]> for (T, T, T, T, T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 11]> for (T, T, T, T, T, T, T, T, T, T, T)

1.71.0 · source§

impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T)

1.34.0 · source§

impl<T> From<!> for T

稳定性注意事项: 该 impl 尚不存在,但我们 “保留空间” 以在将来添加它。 有关详细信息,请参见 rust-lang/rust#64715

1.23.0 · source§

impl<T> From<*mut T> for AtomicPtr<T>

1.25.0 · source§

impl<T> From<&T> for NonNull<T>where T: ?Sized,

1.25.0 · source§

impl<T> From<&mut T> for NonNull<T>where T: ?Sized,

1.71.0 · source§

impl<T> From<(T, T)> for [T; 2]

1.71.0 · source§

impl<T> From<(T, T, T)> for [T; 3]

1.71.0 · source§

impl<T> From<(T, T, T, T)> for [T; 4]

1.71.0 · source§

impl<T> From<(T, T, T, T, T)> for [T; 5]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T)> for [T; 6]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T)> for [T; 7]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T, T)> for [T; 8]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T, T, T)> for [T; 9]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T, T, T, T)> for [T; 10]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T, T, T, T, T)> for [T; 11]

1.71.0 · source§

impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12]

1.71.0 · source§

impl<T> From<(T,)> for [T; 1]

1.21.0 · source§

impl<T> From<Box<T, Global>> for Rc<T>where T: ?Sized,

1.21.0 · source§

impl<T> From<Box<T, Global>> for Arc<T>where T: ?Sized,

1.5.0 · source§

impl<T> From<BinaryHeap<T>> for Vec<T, Global>

1.24.0 · source§

impl<T> From<SendError<T>> for TrySendError<T>

source§

impl<T> From<PoisonError<T>> for TryLockError<T>

1.63.0 · source§

impl<T> From<JoinHandle<T>> for OwnedHandle

Available on Windows only.
1.5.0 · source§

impl<T> From<Vec<T, Global>> for BinaryHeap<T>where T: Ord,

1.21.0 · source§

impl<T> From<Vec<T, Global>> for Rc<[T]>

1.21.0 · source§

impl<T> From<Vec<T, Global>> for Arc<[T]>

1.12.0 · source§

impl<T> From<T> for Option<T>

1.36.0 · source§

impl<T> From<T> for Poll<T>

1.6.0 · source§

impl<T> From<T> for Box<T, Global>

1.12.0 · source§

impl<T> From<T> for Cell<T>

1.70.0 · source§

impl<T> From<T> for OnceCell<T>

1.12.0 · source§

impl<T> From<T> for RefCell<T>

source§

impl<T> From<T> for SyncUnsafeCell<T>

1.12.0 · source§

impl<T> From<T> for UnsafeCell<T>

1.6.0 · source§

impl<T> From<T> for Rc<T>

1.6.0 · source§

impl<T> From<T> for Arc<T>

source§

impl<T> From<T> for Exclusive<T>

1.24.0 · source§

impl<T> From<T> for Mutex<T>

1.70.0 · source§

impl<T> From<T> for OnceLock<T>

1.24.0 · source§

impl<T> From<T> for RwLock<T>

source§

impl<T> From<T> for T

1.18.0 · source§

impl<T, A> From<Box<[T], A>> for Vec<T, A>where A: Allocator,

1.33.0 · source§

impl<T, A> From<Box<T, A>> for Pin<Box<T, A>>where A: Allocator + 'static, T: ?Sized,

1.10.0 · source§

impl<T, A> From<VecDeque<T, A>> for Vec<T, A>where A: Allocator,

1.20.0 · source§

impl<T, A> From<Vec<T, A>> for Box<[T], A>where A: Allocator,

1.10.0 · source§

impl<T, A> From<Vec<T, A>> for VecDeque<T, A>where A: Allocator,

source§

impl<T, const LANES: usize> From<Mask<T, LANES>> for [bool; LANES]where T: MaskElement, LaneCount<LANES>: SupportedLaneCount,

source§

impl<T, const LANES: usize> From<Mask<T, LANES>> for Simd<T, LANES>where T: MaskElement, LaneCount<LANES>: SupportedLaneCount,

source§

impl<T, const LANES: usize> From<[bool; LANES]> for Mask<T, LANES>where T: MaskElement, LaneCount<LANES>: SupportedLaneCount,

1.45.0 · source§

impl<T, const N: usize> From<[T; N]> for Box<[T], Global>

1.56.0 · source§

impl<T, const N: usize> From<[T; N]> for HashSet<T, RandomState>where T: Eq + Hash,

1.56.0 · source§

impl<T, const N: usize> From<[T; N]> for BTreeSet<T, Global>where T: Ord,

1.56.0 · source§

impl<T, const N: usize> From<[T; N]> for BinaryHeap<T>where T: Ord,

1.56.0 · source§

impl<T, const N: usize> From<[T; N]> for LinkedList<T, Global>

1.56.0 · source§

impl<T, const N: usize> From<[T; N]> for VecDeque<T, Global>

source§

impl<T, const N: usize> From<[T; N]> for Simd<T, N>where LaneCount<N>: SupportedLaneCount, T: SimdElement,

1.44.0 · source§

impl<T, const N: usize> From<[T; N]> for Vec<T, Global>

source§

impl<T, const N: usize> From<Simd<T, N>> for [T; N]where LaneCount<N>: SupportedLaneCount, T: SimdElement,

source§

impl<T: ?Sized + AsRef<OsStr>> From<&T> for OsString

source§

impl<T: ?Sized + AsRef<OsStr>> From<&T> for PathBuf

source§

impl<W> From<IntoInnerError<W>> for Error

1.51.0 · source§

impl<W> From<Arc<W>> for RawWakerwhere W: Wake + Send + Sync + 'static,

1.51.0 · source§

impl<W> From<Arc<W>> for Wakerwhere W: Wake + Send + Sync + 'static,

source§

impl<const LANES: usize> From<Mask<i8, LANES>> for Mask<i16, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i8, LANES>> for Mask<i32, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i8, LANES>> for Mask<i64, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i8, LANES>> for Mask<isize, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i16, LANES>> for Mask<i8, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i16, LANES>> for Mask<i32, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i16, LANES>> for Mask<i64, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i16, LANES>> for Mask<isize, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i32, LANES>> for Mask<i8, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i32, LANES>> for Mask<i16, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i32, LANES>> for Mask<i64, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i32, LANES>> for Mask<isize, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i64, LANES>> for Mask<i8, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i64, LANES>> for Mask<i16, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i64, LANES>> for Mask<i32, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<i64, LANES>> for Mask<isize, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<isize, LANES>> for Mask<i8, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<isize, LANES>> for Mask<i16, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<isize, LANES>> for Mask<i32, LANES>where LaneCount<LANES>: SupportedLaneCount,

source§

impl<const LANES: usize> From<Mask<isize, LANES>> for Mask<i64, LANES>where LaneCount<LANES>: SupportedLaneCount,