Skip to content

Make doctests of Ipv4Addr::from(u32) easier to read #75175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,8 @@ impl From<Ipv4Addr> for u32 {
/// ```
/// use std::net::Ipv4Addr;
///
/// let addr = Ipv4Addr::new(13, 12, 11, 10);
/// assert_eq!(0x0d0c0b0au32, u32::from(addr));
/// let addr = Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe);
/// assert_eq!(0xcafebabe, u32::from(addr));
/// ```
fn from(ip: Ipv4Addr) -> u32 {
let ip = ip.octets();
Expand All @@ -1000,8 +1000,8 @@ impl From<u32> for Ipv4Addr {
/// ```
/// use std::net::Ipv4Addr;
///
/// let addr = Ipv4Addr::from(0x0d0c0b0au32);
/// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
/// let addr = Ipv4Addr::from(0xcafebabe);
/// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr);
/// ```
fn from(ip: u32) -> Ipv4Addr {
Ipv4Addr::from(ip.to_be_bytes())
Expand Down