@@ -294,7 +294,7 @@ impl FormattingOptions {
294
294
/// - no precision, and
295
295
/// - no [`DebugAsHex`] output mode.
296
296
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
297
- pub fn new ( ) -> Self {
297
+ pub const fn new ( ) -> Self {
298
298
Self {
299
299
sign : None ,
300
300
sign_aware_zero_pad : false ,
@@ -316,15 +316,15 @@ impl FormattingOptions {
316
316
/// always be printed.
317
317
/// - `-`: Currently not used
318
318
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
319
- pub fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
319
+ pub const fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
320
320
self . sign = sign;
321
321
self
322
322
}
323
323
/// Sets or unsets the `0` flag.
324
324
///
325
325
/// 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
326
326
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
327
- pub fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
327
+ pub const fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
328
328
self . sign_aware_zero_pad = sign_aware_zero_pad;
329
329
self
330
330
}
@@ -337,7 +337,7 @@ impl FormattingOptions {
337
337
/// - [`Octal`] - precedes the argument with a `0b`
338
338
/// - [`Binary`] - precedes the argument with a `0o`
339
339
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
340
- pub fn alternate ( & mut self , alternate : bool ) -> & mut Self {
340
+ pub const fn alternate ( & mut self , alternate : bool ) -> & mut Self {
341
341
self . alternate = alternate;
342
342
self
343
343
}
@@ -348,7 +348,7 @@ impl FormattingOptions {
348
348
/// being formatted is smaller than width some extra characters will be
349
349
/// printed around it.
350
350
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
351
- pub fn fill ( & mut self , fill : char ) -> & mut Self {
351
+ pub const fn fill ( & mut self , fill : char ) -> & mut Self {
352
352
self . fill = fill;
353
353
self
354
354
}
@@ -357,7 +357,7 @@ impl FormattingOptions {
357
357
/// The alignment specifies how the value being formatted should be
358
358
/// positioned if it is smaller than the width of the formatter.
359
359
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
360
- pub fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
360
+ pub const fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
361
361
self . align = align;
362
362
self
363
363
}
@@ -368,7 +368,7 @@ impl FormattingOptions {
368
368
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
369
369
/// will be used to take up the required space.
370
370
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
371
- pub fn width ( & mut self , width : Option < usize > ) -> & mut Self {
371
+ pub const fn width ( & mut self , width : Option < usize > ) -> & mut Self {
372
372
self . width = width;
373
373
self
374
374
}
@@ -382,64 +382,64 @@ impl FormattingOptions {
382
382
/// - For floating-point types, this indicates how many digits after the
383
383
/// decimal point should be printed.
384
384
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
385
- pub fn precision ( & mut self , precision : Option < usize > ) -> & mut Self {
385
+ pub const fn precision ( & mut self , precision : Option < usize > ) -> & mut Self {
386
386
self . precision = precision;
387
387
self
388
388
}
389
389
/// Specifies whether the [`Debug`] trait should use lower-/upper-case
390
390
/// hexadecimal or normal integers
391
391
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
392
- pub fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
392
+ pub const fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
393
393
self . debug_as_hex = debug_as_hex;
394
394
self
395
395
}
396
396
397
397
/// Returns the current sign (the `+` or the `-` flag).
398
398
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
399
- pub fn get_sign ( & self ) -> Option < Sign > {
399
+ pub const fn get_sign ( & self ) -> Option < Sign > {
400
400
self . sign
401
401
}
402
402
/// Returns the current `0` flag.
403
403
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
404
- pub fn get_sign_aware_zero_pad ( & self ) -> bool {
404
+ pub const fn get_sign_aware_zero_pad ( & self ) -> bool {
405
405
self . sign_aware_zero_pad
406
406
}
407
407
/// Returns the current `#` flag.
408
408
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
409
- pub fn get_alternate ( & self ) -> bool {
409
+ pub const fn get_alternate ( & self ) -> bool {
410
410
self . alternate
411
411
}
412
412
/// Returns the current fill character.
413
413
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
414
- pub fn get_fill ( & self ) -> char {
414
+ pub const fn get_fill ( & self ) -> char {
415
415
self . fill
416
416
}
417
417
/// Returns the current alignment.
418
418
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
419
- pub fn get_align ( & self ) -> Option < Alignment > {
419
+ pub const fn get_align ( & self ) -> Option < Alignment > {
420
420
self . align
421
421
}
422
422
/// Returns the current width.
423
423
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
424
- pub fn get_width ( & self ) -> Option < usize > {
424
+ pub const fn get_width ( & self ) -> Option < usize > {
425
425
self . width
426
426
}
427
427
/// Returns the current precision.
428
428
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
429
- pub fn get_precision ( & self ) -> Option < usize > {
429
+ pub const fn get_precision ( & self ) -> Option < usize > {
430
430
self . precision
431
431
}
432
432
/// Returns the current precision.
433
433
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
434
- pub fn get_debug_as_hex ( & self ) -> Option < DebugAsHex > {
434
+ pub const fn get_debug_as_hex ( & self ) -> Option < DebugAsHex > {
435
435
self . debug_as_hex
436
436
}
437
437
438
438
/// Creates a [`Formatter`] that writes its output to the given [`Write`] trait.
439
439
///
440
440
/// You may alternatively use [`Formatter::new()`].
441
441
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
442
- pub fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
442
+ pub const fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
443
443
Formatter { options : self , buf : write }
444
444
}
445
445
@@ -508,13 +508,13 @@ impl<'a> Formatter<'a> {
508
508
///
509
509
/// You may alternatively use [`FormattingOptions::create_formatter()`].
510
510
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
511
- pub fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
511
+ pub const fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
512
512
Formatter { options, buf : write }
513
513
}
514
514
515
515
/// Creates a new formatter based on this one with given [`FormattingOptions`].
516
516
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
517
- pub fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
517
+ pub const fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
518
518
Formatter { options, buf : self . buf }
519
519
}
520
520
}
@@ -2494,13 +2494,13 @@ impl<'a> Formatter<'a> {
2494
2494
2495
2495
/// Returns the sign of this formatter (`+` or `-`).
2496
2496
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
2497
- pub fn sign ( & self ) -> Option < Sign > {
2497
+ pub const fn sign ( & self ) -> Option < Sign > {
2498
2498
self . options . get_sign ( )
2499
2499
}
2500
2500
2501
2501
/// Returns the formatting options this formatter corresponds to.
2502
2502
#[ unstable( feature = "formatting_options" , issue = "118117" ) ]
2503
- pub fn options ( & self ) -> FormattingOptions {
2503
+ pub const fn options ( & self ) -> FormattingOptions {
2504
2504
self . options
2505
2505
}
2506
2506
}
0 commit comments