Skip to content

Commit c9c7048

Browse files
authored
Rollup merge of #75175 - lzutao:doctest-ipv4-fromu32, r=cuviper
Make doctests of Ipv4Addr::from(u32) easier to read There are many zeroes in `0x0d0c0b0au32` which makes it hard to read.
2 parents 9d5bd59 + 725d37c commit c9c7048

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/std/src/net/ip.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ impl From<Ipv4Addr> for u32 {
976976
/// ```
977977
/// use std::net::Ipv4Addr;
978978
///
979-
/// let addr = Ipv4Addr::new(13, 12, 11, 10);
980-
/// assert_eq!(0x0d0c0b0au32, u32::from(addr));
979+
/// let addr = Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe);
980+
/// assert_eq!(0xcafebabe, u32::from(addr));
981981
/// ```
982982
fn from(ip: Ipv4Addr) -> u32 {
983983
let ip = ip.octets();
@@ -994,8 +994,8 @@ impl From<u32> for Ipv4Addr {
994994
/// ```
995995
/// use std::net::Ipv4Addr;
996996
///
997-
/// let addr = Ipv4Addr::from(0x0d0c0b0au32);
998-
/// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
997+
/// let addr = Ipv4Addr::from(0xcafebabe);
998+
/// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr);
999999
/// ```
10001000
fn from(ip: u32) -> Ipv4Addr {
10011001
Ipv4Addr::from(ip.to_be_bytes())

0 commit comments

Comments
 (0)