Skip to content

Commit 42408d7

Browse files
committed
Add a scope ID case to example code for SocketAddrV6
1 parent a0a18d3 commit 42408d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/net/socket_addr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ pub struct SocketAddrV4 {
127127
/// assert_eq!("[2001:db8::1]:8080".parse(), Ok(socket));
128128
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1));
129129
/// assert_eq!(socket.port(), 8080);
130+
///
131+
/// let mut with_scope = socket.clone();
132+
/// with_scope.set_scope_id(3);
133+
/// assert_eq!("[2001:db8::1%3]:8080".parse(), Ok(with_scope));
130134
/// ```
131135
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
132136
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)