Struct std::net::AddrParseError1.0.0[−][src]

pub struct AddrParseError(_);
Expand description

解析 IP 地址或套接字地址时可以返回的错误。

该错误用作 IpAddr,Ipv4Addr,Ipv6Addr,SocketAddr,SocketAddrV4 和 SocketAddrV6 的 FromStr 实现的错误类型。

潜在原因

AddrParseError 可能因为提供的字符串未解析为给定的类型而抛出,通常是因为它包含仅由不同地址类型处理的信息。

ⓘ
use std::net::IpAddr;
let _foo: IpAddr = "127.0.0.1:8080".parse().expect("Cannot handle the socket port");
Run

IpAddr 不处理端口。请改用 SocketAddr。

use std::net::SocketAddr;

// 没问题,`panic!` 消息已消失。
let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic");
Run

Trait Implementations

返回值的副本。 Read more

从 source 执行复制分配。 Read more

使用给定的格式化程序格式化该值。 Read more

使用给定的格式化程序格式化该值。 Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

此错误的下级来源 (如果有)。 Read more

🔬 This is a nightly-only experimental API. (backtrace #53487)

返回发生错误的栈回溯 (如果有)。 Read more

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

此方法测试 self 和 other 值是否相等,并由 == 使用。 Read more

此方法测试 !=。

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

获得所有权后的结果类型。

通常通过克隆从借用数据中创建拥有的数据。 Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

recently added

使用借来的数据来替换拥有的数据,通常是通过克隆。 Read more

将给定值转换为 String。 Read more

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。