@@ -122,6 +122,7 @@ impl SocketAddr {
122
122
#[ stable( feature = "ip_addr" , since = "1.7.0" ) ]
123
123
#[ must_use]
124
124
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
125
+ #[ inline]
125
126
pub const fn new ( ip : IpAddr , port : u16 ) -> SocketAddr {
126
127
match ip {
127
128
IpAddr :: V4 ( a) => SocketAddr :: V4 ( SocketAddrV4 :: new ( a, port) ) ,
@@ -142,6 +143,7 @@ impl SocketAddr {
142
143
#[ must_use]
143
144
#[ stable( feature = "ip_addr" , since = "1.7.0" ) ]
144
145
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
146
+ #[ inline]
145
147
pub const fn ip ( & self ) -> IpAddr {
146
148
match * self {
147
149
SocketAddr :: V4 ( ref a) => IpAddr :: V4 ( * a. ip ( ) ) ,
@@ -161,6 +163,7 @@ impl SocketAddr {
161
163
/// assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
162
164
/// ```
163
165
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
166
+ #[ inline]
164
167
pub fn set_ip ( & mut self , new_ip : IpAddr ) {
165
168
// `match (*self, new_ip)` would have us mutate a copy of self only to throw it away.
166
169
match ( self , new_ip) {
@@ -183,6 +186,7 @@ impl SocketAddr {
183
186
#[ must_use]
184
187
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
185
188
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
189
+ #[ inline]
186
190
pub const fn port ( & self ) -> u16 {
187
191
match * self {
188
192
SocketAddr :: V4 ( ref a) => a. port ( ) ,
@@ -202,6 +206,7 @@ impl SocketAddr {
202
206
/// assert_eq!(socket.port(), 1025);
203
207
/// ```
204
208
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
209
+ #[ inline]
205
210
pub fn set_port ( & mut self , new_port : u16 ) {
206
211
match * self {
207
212
SocketAddr :: V4 ( ref mut a) => a. set_port ( new_port) ,
@@ -227,6 +232,7 @@ impl SocketAddr {
227
232
#[ must_use]
228
233
#[ stable( feature = "sockaddr_checker" , since = "1.16.0" ) ]
229
234
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
235
+ #[ inline]
230
236
pub const fn is_ipv4 ( & self ) -> bool {
231
237
matches ! ( * self , SocketAddr :: V4 ( _) )
232
238
}
@@ -249,6 +255,7 @@ impl SocketAddr {
249
255
#[ must_use]
250
256
#[ stable( feature = "sockaddr_checker" , since = "1.16.0" ) ]
251
257
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
258
+ #[ inline]
252
259
pub const fn is_ipv6 ( & self ) -> bool {
253
260
matches ! ( * self , SocketAddr :: V6 ( _) )
254
261
}
@@ -269,6 +276,7 @@ impl SocketAddrV4 {
269
276
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
270
277
#[ must_use]
271
278
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
279
+ #[ inline]
272
280
pub const fn new ( ip : Ipv4Addr , port : u16 ) -> SocketAddrV4 {
273
281
SocketAddrV4 { ip, port }
274
282
}
@@ -286,6 +294,7 @@ impl SocketAddrV4 {
286
294
#[ must_use]
287
295
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
288
296
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
297
+ #[ inline]
289
298
pub const fn ip ( & self ) -> & Ipv4Addr {
290
299
& self . ip
291
300
}
@@ -302,6 +311,7 @@ impl SocketAddrV4 {
302
311
/// assert_eq!(socket.ip(), &Ipv4Addr::new(192, 168, 0, 1));
303
312
/// ```
304
313
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
314
+ #[ inline]
305
315
pub fn set_ip ( & mut self , new_ip : Ipv4Addr ) {
306
316
self . ip = new_ip;
307
317
}
@@ -319,6 +329,7 @@ impl SocketAddrV4 {
319
329
#[ must_use]
320
330
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
321
331
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
332
+ #[ inline]
322
333
pub const fn port ( & self ) -> u16 {
323
334
self . port
324
335
}
@@ -335,6 +346,7 @@ impl SocketAddrV4 {
335
346
/// assert_eq!(socket.port(), 4242);
336
347
/// ```
337
348
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
349
+ #[ inline]
338
350
pub fn set_port ( & mut self , new_port : u16 ) {
339
351
self . port = new_port;
340
352
}
@@ -360,6 +372,7 @@ impl SocketAddrV6 {
360
372
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
361
373
#[ must_use]
362
374
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
375
+ #[ inline]
363
376
pub const fn new ( ip : Ipv6Addr , port : u16 , flowinfo : u32 , scope_id : u32 ) -> SocketAddrV6 {
364
377
SocketAddrV6 { ip, port, flowinfo, scope_id }
365
378
}
@@ -377,6 +390,7 @@ impl SocketAddrV6 {
377
390
#[ must_use]
378
391
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
379
392
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
393
+ #[ inline]
380
394
pub const fn ip ( & self ) -> & Ipv6Addr {
381
395
& self . ip
382
396
}
@@ -393,6 +407,7 @@ impl SocketAddrV6 {
393
407
/// assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
394
408
/// ```
395
409
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
410
+ #[ inline]
396
411
pub fn set_ip ( & mut self , new_ip : Ipv6Addr ) {
397
412
self . ip = new_ip;
398
413
}
@@ -410,6 +425,7 @@ impl SocketAddrV6 {
410
425
#[ must_use]
411
426
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
412
427
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
428
+ #[ inline]
413
429
pub const fn port ( & self ) -> u16 {
414
430
self . port
415
431
}
@@ -426,6 +442,7 @@ impl SocketAddrV6 {
426
442
/// assert_eq!(socket.port(), 4242);
427
443
/// ```
428
444
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
445
+ #[ inline]
429
446
pub fn set_port ( & mut self , new_port : u16 ) {
430
447
self . port = new_port;
431
448
}
@@ -453,6 +470,7 @@ impl SocketAddrV6 {
453
470
#[ must_use]
454
471
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
455
472
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
473
+ #[ inline]
456
474
pub const fn flowinfo ( & self ) -> u32 {
457
475
self . flowinfo
458
476
}
@@ -471,6 +489,7 @@ impl SocketAddrV6 {
471
489
/// assert_eq!(socket.flowinfo(), 56);
472
490
/// ```
473
491
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
492
+ #[ inline]
474
493
pub fn set_flowinfo ( & mut self , new_flowinfo : u32 ) {
475
494
self . flowinfo = new_flowinfo;
476
495
}
@@ -493,6 +512,7 @@ impl SocketAddrV6 {
493
512
#[ must_use]
494
513
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
495
514
#[ rustc_const_stable( feature = "const_socketaddr" , since = "1.69.0" ) ]
515
+ #[ inline]
496
516
pub const fn scope_id ( & self ) -> u32 {
497
517
self . scope_id
498
518
}
@@ -511,6 +531,7 @@ impl SocketAddrV6 {
511
531
/// assert_eq!(socket.scope_id(), 42);
512
532
/// ```
513
533
#[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
534
+ #[ inline]
514
535
pub fn set_scope_id ( & mut self , new_scope_id : u32 ) {
515
536
self . scope_id = new_scope_id;
516
537
}
@@ -519,6 +540,7 @@ impl SocketAddrV6 {
519
540
#[ stable( feature = "ip_from_ip" , since = "1.16.0" ) ]
520
541
impl From < SocketAddrV4 > for SocketAddr {
521
542
/// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`].
543
+ #[ inline]
522
544
fn from ( sock4 : SocketAddrV4 ) -> SocketAddr {
523
545
SocketAddr :: V4 ( sock4)
524
546
}
@@ -527,6 +549,7 @@ impl From<SocketAddrV4> for SocketAddr {
527
549
#[ stable( feature = "ip_from_ip" , since = "1.16.0" ) ]
528
550
impl From < SocketAddrV6 > for SocketAddr {
529
551
/// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`].
552
+ #[ inline]
530
553
fn from ( sock6 : SocketAddrV6 ) -> SocketAddr {
531
554
SocketAddr :: V6 ( sock6)
532
555
}
@@ -624,27 +647,31 @@ impl fmt::Debug for SocketAddrV6 {
624
647
625
648
#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
626
649
impl PartialOrd for SocketAddrV4 {
650
+ #[ inline]
627
651
fn partial_cmp ( & self , other : & SocketAddrV4 ) -> Option < Ordering > {
628
652
Some ( self . cmp ( other) )
629
653
}
630
654
}
631
655
632
656
#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
633
657
impl PartialOrd for SocketAddrV6 {
658
+ #[ inline]
634
659
fn partial_cmp ( & self , other : & SocketAddrV6 ) -> Option < Ordering > {
635
660
Some ( self . cmp ( other) )
636
661
}
637
662
}
638
663
639
664
#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
640
665
impl Ord for SocketAddrV4 {
666
+ #[ inline]
641
667
fn cmp ( & self , other : & SocketAddrV4 ) -> Ordering {
642
668
self . ip ( ) . cmp ( other. ip ( ) ) . then ( self . port ( ) . cmp ( & other. port ( ) ) )
643
669
}
644
670
}
645
671
646
672
#[ stable( feature = "socketaddr_ordering" , since = "1.45.0" ) ]
647
673
impl Ord for SocketAddrV6 {
674
+ #[ inline]
648
675
fn cmp ( & self , other : & SocketAddrV6 ) -> Ordering {
649
676
self . ip ( ) . cmp ( other. ip ( ) ) . then ( self . port ( ) . cmp ( & other. port ( ) ) )
650
677
}
0 commit comments