@@ -198,9 +198,10 @@ impl SocketAddr {
198
198
/// socket.set_ip(IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
199
199
/// assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
200
200
/// ```
201
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
202
201
#[ inline]
203
- pub fn set_ip ( & mut self , new_ip : IpAddr ) {
202
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
203
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
204
+ pub const fn set_ip ( & mut self , new_ip : IpAddr ) {
204
205
// `match (*self, new_ip)` would have us mutate a copy of self only to throw it away.
205
206
match ( self , new_ip) {
206
207
( & mut SocketAddr :: V4 ( ref mut a) , IpAddr :: V4 ( new_ip) ) => a. set_ip ( new_ip) ,
@@ -241,9 +242,10 @@ impl SocketAddr {
241
242
/// socket.set_port(1025);
242
243
/// assert_eq!(socket.port(), 1025);
243
244
/// ```
244
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
245
245
#[ inline]
246
- pub fn set_port ( & mut self , new_port : u16 ) {
246
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
247
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
248
+ pub const fn set_port ( & mut self , new_port : u16 ) {
247
249
match * self {
248
250
SocketAddr :: V4 ( ref mut a) => a. set_port ( new_port) ,
249
251
SocketAddr :: V6 ( ref mut a) => a. set_port ( new_port) ,
@@ -346,9 +348,10 @@ impl SocketAddrV4 {
346
348
/// socket.set_ip(Ipv4Addr::new(192, 168, 0, 1));
347
349
/// assert_eq!(socket.ip(), &Ipv4Addr::new(192, 168, 0, 1));
348
350
/// ```
349
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
350
351
#[ inline]
351
- pub fn set_ip ( & mut self , new_ip : Ipv4Addr ) {
352
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
353
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
354
+ pub const fn set_ip ( & mut self , new_ip : Ipv4Addr ) {
352
355
self . ip = new_ip;
353
356
}
354
357
@@ -381,9 +384,10 @@ impl SocketAddrV4 {
381
384
/// socket.set_port(4242);
382
385
/// assert_eq!(socket.port(), 4242);
383
386
/// ```
384
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
385
387
#[ inline]
386
- pub fn set_port ( & mut self , new_port : u16 ) {
388
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
389
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
390
+ pub const fn set_port ( & mut self , new_port : u16 ) {
387
391
self . port = new_port;
388
392
}
389
393
}
@@ -442,9 +446,10 @@ impl SocketAddrV6 {
442
446
/// socket.set_ip(Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
443
447
/// assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
444
448
/// ```
445
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
446
449
#[ inline]
447
- pub fn set_ip ( & mut self , new_ip : Ipv6Addr ) {
450
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
451
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
452
+ pub const fn set_ip ( & mut self , new_ip : Ipv6Addr ) {
448
453
self . ip = new_ip;
449
454
}
450
455
@@ -477,9 +482,10 @@ impl SocketAddrV6 {
477
482
/// socket.set_port(4242);
478
483
/// assert_eq!(socket.port(), 4242);
479
484
/// ```
480
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
481
485
#[ inline]
482
- pub fn set_port ( & mut self , new_port : u16 ) {
486
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
487
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
488
+ pub const fn set_port ( & mut self , new_port : u16 ) {
483
489
self . port = new_port;
484
490
}
485
491
@@ -524,9 +530,10 @@ impl SocketAddrV6 {
524
530
/// socket.set_flowinfo(56);
525
531
/// assert_eq!(socket.flowinfo(), 56);
526
532
/// ```
527
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
528
533
#[ inline]
529
- pub fn set_flowinfo ( & mut self , new_flowinfo : u32 ) {
534
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
535
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
536
+ pub const fn set_flowinfo ( & mut self , new_flowinfo : u32 ) {
530
537
self . flowinfo = new_flowinfo;
531
538
}
532
539
@@ -566,9 +573,10 @@ impl SocketAddrV6 {
566
573
/// socket.set_scope_id(42);
567
574
/// assert_eq!(socket.scope_id(), 42);
568
575
/// ```
569
- #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
570
576
#[ inline]
571
- pub fn set_scope_id ( & mut self , new_scope_id : u32 ) {
577
+ #[ stable( feature = "sockaddr_setters" , since = "1.9.0" ) ]
578
+ #[ rustc_const_unstable( feature = "const_sockaddr_setters" , issue = "131714" ) ]
579
+ pub const fn set_scope_id ( & mut self , new_scope_id : u32 ) {
572
580
self . scope_id = new_scope_id;
573
581
}
574
582
}
0 commit comments