@@ -122,6 +122,7 @@ impl SocketAddr {
122122 #[ stable( feature = "ip_addr" , since = "1.7.0" ) ]
123123 #[ must_use]
124124 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
125+ #[ inline]
125126 pub const fn new ( ip : IpAddr , port : u16 ) -> SocketAddr {
126127 match ip {
127128 IpAddr :: V4 ( a) => SocketAddr :: V4 ( SocketAddrV4 :: new ( a, port) ) ,
@@ -142,6 +143,7 @@ impl SocketAddr {
142143 #[ must_use]
143144 #[ stable( feature = "ip_addr" , since = "1.7.0" ) ]
144145 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
146+ #[ inline]
145147 pub const fn ip ( & self ) -> IpAddr {
146148 match * self {
147149 SocketAddr :: V4 ( ref a) => IpAddr :: V4 ( * a. ip ( ) ) ,
@@ -161,6 +163,7 @@ impl SocketAddr {
161163 /// assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
162164 /// ```
163165 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
166+ #[ inline]
164167 pub fn set_ip ( & mut self , new_ip : IpAddr ) {
165168 // `match (*self, new_ip)` would have us mutate a copy of self only to throw it away.
166169 match ( self , new_ip) {
@@ -183,6 +186,7 @@ impl SocketAddr {
183186 #[ must_use]
184187 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
185188 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
189+ #[ inline]
186190 pub const fn port ( & self ) -> u16 {
187191 match * self {
188192 SocketAddr :: V4 ( ref a) => a. port ( ) ,
@@ -202,6 +206,7 @@ impl SocketAddr {
202206 /// assert_eq!(socket.port(), 1025);
203207 /// ```
204208 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
209+ #[ inline]
205210 pub fn set_port ( & mut self , new_port : u16 ) {
206211 match * self {
207212 SocketAddr :: V4 ( ref mut a) => a. set_port ( new_port) ,
@@ -227,6 +232,7 @@ impl SocketAddr {
227232 #[ must_use]
228233 #[ stable( feature = "sockaddr_checker" , since = "1.16.0" ) ]
229234 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
235+ #[ inline]
230236 pub const fn is_ipv4 ( & self ) -> bool {
231237 matches ! ( * self , SocketAddr :: V4 ( _) )
232238 }
@@ -249,6 +255,7 @@ impl SocketAddr {
249255 #[ must_use]
250256 #[ stable( feature = "sockaddr_checker" , since = "1.16.0" ) ]
251257 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
258+ #[ inline]
252259 pub const fn is_ipv6 ( & self ) -> bool {
253260 matches ! ( * self , SocketAddr :: V6 ( _) )
254261 }
@@ -269,6 +276,7 @@ impl SocketAddrV4 {
269276 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
270277 #[ must_use]
271278 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
279+ #[ inline]
272280 pub const fn new ( ip : Ipv4Addr , port : u16 ) -> SocketAddrV4 {
273281 SocketAddrV4 { ip, port }
274282 }
@@ -286,6 +294,7 @@ impl SocketAddrV4 {
286294 #[ must_use]
287295 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
288296 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
297+ #[ inline]
289298 pub const fn ip ( & self ) -> & Ipv4Addr {
290299 & self . ip
291300 }
@@ -302,6 +311,7 @@ impl SocketAddrV4 {
302311 /// assert_eq!(socket.ip(), &Ipv4Addr::new(192, 168, 0, 1));
303312 /// ```
304313 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
314+ #[ inline]
305315 pub fn set_ip ( & mut self , new_ip : Ipv4Addr ) {
306316 self . ip = new_ip;
307317 }
@@ -319,6 +329,7 @@ impl SocketAddrV4 {
319329 #[ must_use]
320330 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
321331 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
332+ #[ inline]
322333 pub const fn port ( & self ) -> u16 {
323334 self . port
324335 }
@@ -335,6 +346,7 @@ impl SocketAddrV4 {
335346 /// assert_eq!(socket.port(), 4242);
336347 /// ```
337348 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
349+ #[ inline]
338350 pub fn set_port ( & mut self , new_port : u16 ) {
339351 self . port = new_port;
340352 }
@@ -360,6 +372,7 @@ impl SocketAddrV6 {
360372 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
361373 #[ must_use]
362374 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
375+ #[ inline]
363376 pub const fn new ( ip : Ipv6Addr , port : u16 , flowinfo : u32 , scope_id : u32 ) -> SocketAddrV6 {
364377 SocketAddrV6 { ip, port, flowinfo, scope_id }
365378 }
@@ -377,6 +390,7 @@ impl SocketAddrV6 {
377390 #[ must_use]
378391 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
379392 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
393+ #[ inline]
380394 pub const fn ip ( & self ) -> & Ipv6Addr {
381395 & self . ip
382396 }
@@ -393,6 +407,7 @@ impl SocketAddrV6 {
393407 /// assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
394408 /// ```
395409 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
410+ #[ inline]
396411 pub fn set_ip ( & mut self , new_ip : Ipv6Addr ) {
397412 self . ip = new_ip;
398413 }
@@ -410,6 +425,7 @@ impl SocketAddrV6 {
410425 #[ must_use]
411426 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
412427 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
428+ #[ inline]
413429 pub const fn port ( & self ) -> u16 {
414430 self . port
415431 }
@@ -426,6 +442,7 @@ impl SocketAddrV6 {
426442 /// assert_eq!(socket.port(), 4242);
427443 /// ```
428444 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
445+ #[ inline]
429446 pub fn set_port ( & mut self , new_port : u16 ) {
430447 self . port = new_port;
431448 }
@@ -453,6 +470,7 @@ impl SocketAddrV6 {
453470 #[ must_use]
454471 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
455472 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
473+ #[ inline]
456474 pub const fn flowinfo ( & self ) -> u32 {
457475 self . flowinfo
458476 }
@@ -471,6 +489,7 @@ impl SocketAddrV6 {
471489 /// assert_eq!(socket.flowinfo(), 56);
472490 /// ```
473491 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
492+ #[ inline]
474493 pub fn set_flowinfo ( & mut self , new_flowinfo : u32 ) {
475494 self . flowinfo = new_flowinfo;
476495 }
@@ -493,6 +512,7 @@ impl SocketAddrV6 {
493512 #[ must_use]
494513 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
495514 #[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
515+ #[ inline]
496516 pub const fn scope_id ( & self ) -> u32 {
497517 self . scope_id
498518 }
@@ -511,6 +531,7 @@ impl SocketAddrV6 {
511531 /// assert_eq!(socket.scope_id(), 42);
512532 /// ```
513533 #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
534+ #[ inline]
514535 pub fn set_scope_id ( & mut self , new_scope_id : u32 ) {
515536 self . scope_id = new_scope_id;
516537 }
@@ -519,6 +540,7 @@ impl SocketAddrV6 {
519540#[ stable( feature = "ip_from_ip" , since = "1.16.0" ) ]
520541impl From < SocketAddrV4 > for SocketAddr {
521542 /// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`].
543+ #[ inline]
522544 fn from ( sock4 : SocketAddrV4 ) -> SocketAddr {
523545 SocketAddr :: V4 ( sock4)
524546 }
@@ -527,6 +549,7 @@ impl From<SocketAddrV4> for SocketAddr {
527549#[ stable( feature = "ip_from_ip" , since = "1.16.0" ) ]
528550impl From < SocketAddrV6 > for SocketAddr {
529551 /// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`].
552+ #[ inline]
530553 fn from ( sock6 : SocketAddrV6 ) -> SocketAddr {
531554 SocketAddr :: V6 ( sock6)
532555 }
@@ -624,27 +647,31 @@ impl fmt::Debug for SocketAddrV6 {
624647
625648#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
626649impl PartialOrd for SocketAddrV4 {
650+ #[ inline]
627651 fn partial_cmp ( & self , other : & SocketAddrV4 ) -> Option < Ordering > {
628652 Some ( self . cmp ( other) )
629653 }
630654}
631655
632656#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
633657impl PartialOrd for SocketAddrV6 {
658+ #[ inline]
634659 fn partial_cmp ( & self , other : & SocketAddrV6 ) -> Option < Ordering > {
635660 Some ( self . cmp ( other) )
636661 }
637662}
638663
639664#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
640665impl Ord for SocketAddrV4 {
666+ #[ inline]
641667 fn cmp ( & self , other : & SocketAddrV4 ) -> Ordering {
642668 self . ip ( ) . cmp ( other. ip ( ) ) . then ( self . port ( ) . cmp ( & other. port ( ) ) )
643669 }
644670}
645671
646672#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
647673impl Ord for SocketAddrV6 {
674+ #[ inline]
648675 fn cmp ( & self , other : & SocketAddrV6 ) -> Ordering {
649676 self . ip ( ) . cmp ( other. ip ( ) ) . then ( self . port ( ) . cmp ( & other. port ( ) ) )
650677 }
0 commit comments