@@ -359,7 +359,7 @@ impl FormattingOptions {
359359/// always be printed.
360360/// - `-`: Currently not used
361361#[ 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 {
363363let sign = match sign {
364364None => 0 ,
365365Some ( Sign :: Plus ) => flags:: SIGN_PLUS_FLAG ,
@@ -372,7 +372,7 @@ impl FormattingOptions {
372372///
373373/// 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
374374#[ 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 {
376376if sign_aware_zero_pad {
377377self . flags |= flags:: SIGN_AWARE_ZERO_PAD_FLAG ;
378378} else {
@@ -389,7 +389,7 @@ impl FormattingOptions {
389389/// - [`Octal`] - precedes the argument with a `0b`
390390/// - [`Binary`] - precedes the argument with a `0o`
391391#[ 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 {
393393if alternate {
394394self . flags |= flags:: ALTERNATE_FLAG ;
395395} else {
@@ -404,7 +404,7 @@ impl FormattingOptions {
404404/// being formatted is smaller than width some extra characters will be
405405/// printed around it.
406406#[ 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 {
408408self . flags = self . flags & ( u32:: MAX << 21 ) | fill as u32 ;
409409self
410410}
@@ -413,7 +413,7 @@ impl FormattingOptions {
413413/// The alignment specifies how the value being formatted should be
414414/// positioned if it is smaller than the width of the formatter.
415415#[ 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 {
417417let align: u32 = match align {
418418Some ( Alignment :: Left ) => flags:: ALIGN_LEFT ,
419419Some ( Alignment :: Right ) => flags:: ALIGN_RIGHT ,
@@ -430,7 +430,7 @@ impl FormattingOptions {
430430/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
431431/// will be used to take up the required space.
432432#[ 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 {
434434if let Some ( width) = width {
435435self . flags |= flags:: WIDTH_FLAG ;
436436self . width = width;
@@ -450,7 +450,7 @@ impl FormattingOptions {
450450/// - For floating-point types, this indicates how many digits after the
451451/// decimal point should be printed.
452452#[ 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 {
454454if let Some ( precision) = precision {
455455self . flags |= flags:: PRECISION_FLAG ;
456456self . precision = precision;
@@ -463,7 +463,7 @@ impl FormattingOptions {
463463/// Specifies whether the [`Debug`] trait should use lower-/upper-case
464464/// hexadecimal or normal integers
465465#[ 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 {
467467let debug_as_hex = match debug_as_hex {
468468None => 0 ,
469469Some ( DebugAsHex :: Lower ) => flags:: DEBUG_LOWER_HEX_FLAG ,
@@ -537,7 +537,7 @@ impl FormattingOptions {
537537///
538538/// You may alternatively use [`Formatter::new()`].
539539#[ 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 > {
541541Formatter { options : self , buf : write }
542542}
543543}
@@ -578,13 +578,13 @@ impl<'a> Formatter<'a> {
578578///
579579/// You may alternatively use [`FormattingOptions::create_formatter()`].
580580#[ 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 {
582582Formatter { options, buf : write }
583583}
584584
585585/// Creates a new formatter based on this one with given [`FormattingOptions`].
586586#[ 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 > {
588588Formatter { options, buf : self . buf }
589589}
590590}
0 commit comments