@@ -359,7 +359,7 @@ impl FormattingOptions {
359
359
/// always be printed.
360
360
/// - `-`: Currently not used
361
361
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
362
- pub fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
362
+ pub const fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
363
363
let sign = match sign {
364
364
None => 0 ,
365
365
Some ( Sign :: Plus ) => flags:: SIGN_PLUS_FLAG ,
@@ -372,7 +372,7 @@ impl FormattingOptions {
372
372
///
373
373
/// This is used to indicate for integer formats that the padding to width should both be done with a 0 character as well as be sign-aware
374
374
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
375
- pub fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
375
+ pub const fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
376
376
if sign_aware_zero_pad {
377
377
self . flags |= flags:: SIGN_AWARE_ZERO_PAD_FLAG ;
378
378
} else {
@@ -389,7 +389,7 @@ impl FormattingOptions {
389
389
/// - [`Octal`] - precedes the argument with a `0b`
390
390
/// - [`Binary`] - precedes the argument with a `0o`
391
391
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
392
- pub fn alternate ( & mut self , alternate : bool ) -> & mut Self {
392
+ pub const fn alternate ( & mut self , alternate : bool ) -> & mut Self {
393
393
if alternate {
394
394
self . flags |= flags:: ALTERNATE_FLAG ;
395
395
} else {
@@ -404,7 +404,7 @@ impl FormattingOptions {
404
404
/// being formatted is smaller than width some extra characters will be
405
405
/// printed around it.
406
406
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
407
- pub fn fill ( & mut self , fill : char ) -> & mut Self {
407
+ pub const fn fill ( & mut self , fill : char ) -> & mut Self {
408
408
self . flags = self . flags & ( u32:: MAX << 21 ) | fill as u32 ;
409
409
self
410
410
}
@@ -413,7 +413,7 @@ impl FormattingOptions {
413
413
/// The alignment specifies how the value being formatted should be
414
414
/// positioned if it is smaller than the width of the formatter.
415
415
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
416
- pub fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
416
+ pub const fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
417
417
let align: u32 = match align {
418
418
Some ( Alignment :: Left ) => flags:: ALIGN_LEFT ,
419
419
Some ( Alignment :: Right ) => flags:: ALIGN_RIGHT ,
@@ -430,7 +430,7 @@ impl FormattingOptions {
430
430
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
431
431
/// will be used to take up the required space.
432
432
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
433
- pub fn width ( & mut self , width : Option < u16 > ) -> & mut Self {
433
+ pub const fn width ( & mut self , width : Option < u16 > ) -> & mut Self {
434
434
if let Some ( width) = width {
435
435
self . flags |= flags:: WIDTH_FLAG ;
436
436
self . width = width;
@@ -450,7 +450,7 @@ impl FormattingOptions {
450
450
/// - For floating-point types, this indicates how many digits after the
451
451
/// decimal point should be printed.
452
452
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
453
- pub fn precision ( & mut self , precision : Option < u16 > ) -> & mut Self {
453
+ pub const fn precision ( & mut self , precision : Option < u16 > ) -> & mut Self {
454
454
if let Some ( precision) = precision {
455
455
self . flags |= flags:: PRECISION_FLAG ;
456
456
self . precision = precision;
@@ -463,7 +463,7 @@ impl FormattingOptions {
463
463
/// Specifies whether the [`Debug`] trait should use lower-/upper-case
464
464
/// hexadecimal or normal integers
465
465
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
466
- pub fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
466
+ pub const fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
467
467
let debug_as_hex = match debug_as_hex {
468
468
None => 0 ,
469
469
Some ( DebugAsHex :: Lower ) => flags:: DEBUG_LOWER_HEX_FLAG ,
@@ -537,7 +537,7 @@ impl FormattingOptions {
537
537
///
538
538
/// You may alternatively use [`Formatter::new()`].
539
539
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
540
- pub fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
540
+ pub const fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
541
541
Formatter { options : self , buf : write }
542
542
}
543
543
}
@@ -578,13 +578,13 @@ impl<'a> Formatter<'a> {
578
578
///
579
579
/// You may alternatively use [`FormattingOptions::create_formatter()`].
580
580
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
581
- pub fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
581
+ pub const fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
582
582
Formatter { options, buf : write }
583
583
}
584
584
585
585
/// Creates a new formatter based on this one with given [`FormattingOptions`].
586
586
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
587
- pub fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
587
+ pub const fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
588
588
Formatter { options, buf : self . buf }
589
589
}
590
590
}
0 commit comments