@@ -310,7 +310,7 @@ impl FormattingOptions {
310310 /// - no precision, and
311311 /// - no [`DebugAsHex`] output mode.
312312 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
313- pub fn new ( ) -> Self {
313+ pub const fn new ( ) -> Self {
314314 Self {
315315 sign : None ,
316316 sign_aware_zero_pad : false ,
@@ -332,15 +332,15 @@ impl FormattingOptions {
332332 /// always be printed.
333333 /// - `-`: Currently not used
334334 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
335- pub fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
335+ pub const fn sign ( & mut self , sign : Option < Sign > ) -> & mut Self {
336336 self . sign = sign;
337337 self
338338 }
339339 /// Sets or unsets the `0` flag.
340340 ///
341341 /// 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
342342 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
343- pub fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
343+ pub const fn sign_aware_zero_pad ( & mut self , sign_aware_zero_pad : bool ) -> & mut Self {
344344 self . sign_aware_zero_pad = sign_aware_zero_pad;
345345 self
346346 }
@@ -353,7 +353,7 @@ impl FormattingOptions {
353353 /// - [`Octal`] - precedes the argument with a `0b`
354354 /// - [`Binary`] - precedes the argument with a `0o`
355355 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
356- pub fn alternate ( & mut self , alternate : bool ) -> & mut Self {
356+ pub const fn alternate ( & mut self , alternate : bool ) -> & mut Self {
357357 self . alternate = alternate;
358358 self
359359 }
@@ -364,7 +364,7 @@ impl FormattingOptions {
364364 /// being formatted is smaller than width some extra characters will be
365365 /// printed around it.
366366 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
367- pub fn fill ( & mut self , fill : char ) -> & mut Self {
367+ pub const fn fill ( & mut self , fill : char ) -> & mut Self {
368368 self . fill = fill;
369369 self
370370 }
@@ -373,7 +373,7 @@ impl FormattingOptions {
373373 /// The alignment specifies how the value being formatted should be
374374 /// positioned if it is smaller than the width of the formatter.
375375 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
376- pub fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
376+ pub const fn align ( & mut self , align : Option < Alignment > ) -> & mut Self {
377377 self . align = align;
378378 self
379379 }
@@ -384,7 +384,7 @@ impl FormattingOptions {
384384 /// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
385385 /// will be used to take up the required space.
386386 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
387- pub fn width ( & mut self , width : Option < usize > ) -> & mut Self {
387+ pub const fn width ( & mut self , width : Option < usize > ) -> & mut Self {
388388 self . width = width;
389389 self
390390 }
@@ -398,64 +398,64 @@ impl FormattingOptions {
398398 /// - For floating-point types, this indicates how many digits after the
399399 /// decimal point should be printed.
400400 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
401- pub fn precision ( & mut self , precision : Option < usize > ) -> & mut Self {
401+ pub const fn precision ( & mut self , precision : Option < usize > ) -> & mut Self {
402402 self . precision = precision;
403403 self
404404 }
405405 /// Specifies whether the [`Debug`] trait should use lower-/upper-case
406406 /// hexadecimal or normal integers
407407 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
408- pub fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
408+ pub const fn debug_as_hex ( & mut self , debug_as_hex : Option < DebugAsHex > ) -> & mut Self {
409409 self . debug_as_hex = debug_as_hex;
410410 self
411411 }
412412
413413 /// Returns the current sign (the `+` or the `-` flag).
414414 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
415- pub fn get_sign ( & self ) -> Option < Sign > {
415+ pub const fn get_sign ( & self ) -> Option < Sign > {
416416 self . sign
417417 }
418418 /// Returns the current `0` flag.
419419 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
420- pub fn get_sign_aware_zero_pad ( & self ) -> bool {
420+ pub const fn get_sign_aware_zero_pad ( & self ) -> bool {
421421 self . sign_aware_zero_pad
422422 }
423423 /// Returns the current `#` flag.
424424 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
425- pub fn get_alternate ( & self ) -> bool {
425+ pub const fn get_alternate ( & self ) -> bool {
426426 self . alternate
427427 }
428428 /// Returns the current fill character.
429429 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
430- pub fn get_fill ( & self ) -> char {
430+ pub const fn get_fill ( & self ) -> char {
431431 self . fill
432432 }
433433 /// Returns the current alignment.
434434 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
435- pub fn get_align ( & self ) -> Option < Alignment > {
435+ pub const fn get_align ( & self ) -> Option < Alignment > {
436436 self . align
437437 }
438438 /// Returns the current width.
439439 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
440- pub fn get_width ( & self ) -> Option < usize > {
440+ pub const fn get_width ( & self ) -> Option < usize > {
441441 self . width
442442 }
443443 /// Returns the current precision.
444444 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
445- pub fn get_precision ( & self ) -> Option < usize > {
445+ pub const fn get_precision ( & self ) -> Option < usize > {
446446 self . precision
447447 }
448448 /// Returns the current precision.
449449 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
450- pub fn get_debug_as_hex ( & self ) -> Option < DebugAsHex > {
450+ pub const fn get_debug_as_hex ( & self ) -> Option < DebugAsHex > {
451451 self . debug_as_hex
452452 }
453453
454454 /// Creates a [`Formatter`] that writes its output to the given [`Write`] trait.
455455 ///
456456 /// You may alternatively use [`Formatter::new()`].
457457 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
458- pub fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
458+ pub const fn create_formatter < ' a > ( self , write : & ' a mut ( dyn Write + ' a ) ) -> Formatter < ' a > {
459459 Formatter { options : self , buf : write }
460460 }
461461
@@ -524,13 +524,13 @@ impl<'a> Formatter<'a> {
524524 ///
525525 /// You may alternatively use [`FormattingOptions::create_formatter()`].
526526 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
527- pub fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
527+ pub const fn new ( write : & ' a mut ( dyn Write + ' a ) , options : FormattingOptions ) -> Self {
528528 Formatter { options, buf : write }
529529 }
530530
531531 /// Creates a new formatter based on this one with given [`FormattingOptions`].
532532 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
533- pub fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
533+ pub const fn with_options < ' b > ( & ' b mut self , options : FormattingOptions ) -> Formatter < ' b > {
534534 Formatter { options, buf : self . buf }
535535 }
536536}
@@ -2584,13 +2584,13 @@ impl<'a> Formatter<'a> {
25842584
25852585 /// Returns the sign of this formatter (`+` or `-`).
25862586 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
2587- pub fn sign ( & self ) -> Option < Sign > {
2587+ pub const fn sign ( & self ) -> Option < Sign > {
25882588 self . options . get_sign ( )
25892589 }
25902590
25912591 /// Returns the formatting options this formatter corresponds to.
25922592 #[ unstable( feature = "formatting_options" , issue = "118117" ) ]
2593- pub fn options ( & self ) -> FormattingOptions {
2593+ pub const fn options ( & self ) -> FormattingOptions {
25942594 self . options
25952595 }
25962596}
0 commit comments