@@ -341,7 +341,7 @@ impl<'a> Arguments<'a> {
341
341
#[ doc( hidden) ] #[ inline]
342
342
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" ,
343
343
issue = "0" ) ]
344
- pub fn new_v1 ( pieces : & ' a [ & ' a str ] ,
344
+ pub const fn new_v1 ( pieces : & ' a [ & ' a str ] ,
345
345
args : & ' a [ ArgumentV1 < ' a > ] ) -> Arguments < ' a > {
346
346
Arguments {
347
347
pieces,
@@ -359,7 +359,7 @@ impl<'a> Arguments<'a> {
359
359
#[ doc( hidden) ] #[ inline]
360
360
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" ,
361
361
issue = "0" ) ]
362
- pub fn new_v1_formatted ( pieces : & ' a [ & ' a str ] ,
362
+ pub const fn new_v1_formatted ( pieces : & ' a [ & ' a str ] ,
363
363
args : & ' a [ ArgumentV1 < ' a > ] ,
364
364
fmt : & ' a [ rt:: v1:: Argument ] ) -> Arguments < ' a > {
365
365
Arguments {
@@ -1492,7 +1492,7 @@ impl<'a> Formatter<'a> {
1492
1492
/// assert_eq!(&format!("{:t>6}", Foo), "tttttt");
1493
1493
/// ```
1494
1494
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1495
- pub fn fill ( & self ) -> char { self . fill }
1495
+ pub const fn fill ( & self ) -> char { self . fill }
1496
1496
1497
1497
/// Flag indicating what form of alignment was requested.
1498
1498
///
@@ -1562,7 +1562,7 @@ impl<'a> Formatter<'a> {
1562
1562
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1563
1563
/// ```
1564
1564
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1565
- pub fn width ( & self ) -> Option < usize > { self . width }
1565
+ pub const fn width ( & self ) -> Option < usize > { self . width }
1566
1566
1567
1567
/// Optionally specified precision for numeric types.
1568
1568
///
@@ -1589,7 +1589,7 @@ impl<'a> Formatter<'a> {
1589
1589
/// assert_eq!(&format!("{}", Foo(23.2)), "Foo(23.20)");
1590
1590
/// ```
1591
1591
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1592
- pub fn precision ( & self ) -> Option < usize > { self . precision }
1592
+ pub const fn precision ( & self ) -> Option < usize > { self . precision }
1593
1593
1594
1594
/// Determines if the `+` flag was specified.
1595
1595
///
@@ -1617,7 +1617,9 @@ impl<'a> Formatter<'a> {
1617
1617
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1618
1618
/// ```
1619
1619
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1620
- pub fn sign_plus ( & self ) -> bool { self . flags & ( 1 << FlagV1 :: SignPlus as u32 ) != 0 }
1620
+ pub const fn sign_plus ( & self ) -> bool {
1621
+ self . flags & ( 1 << FlagV1 :: SignPlus as u32 ) != 0
1622
+ }
1621
1623
1622
1624
/// Determines if the `-` flag was specified.
1623
1625
///
@@ -1643,7 +1645,9 @@ impl<'a> Formatter<'a> {
1643
1645
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1644
1646
/// ```
1645
1647
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1646
- pub fn sign_minus ( & self ) -> bool { self . flags & ( 1 << FlagV1 :: SignMinus as u32 ) != 0 }
1648
+ pub const fn sign_minus ( & self ) -> bool {
1649
+ self . flags & ( 1 << FlagV1 :: SignMinus as u32 ) != 0
1650
+ }
1647
1651
1648
1652
/// Determines if the `#` flag was specified.
1649
1653
///
@@ -1668,7 +1672,9 @@ impl<'a> Formatter<'a> {
1668
1672
/// assert_eq!(&format!("{}", Foo(23)), "23");
1669
1673
/// ```
1670
1674
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1671
- pub fn alternate ( & self ) -> bool { self . flags & ( 1 << FlagV1 :: Alternate as u32 ) != 0 }
1675
+ pub const fn alternate ( & self ) -> bool {
1676
+ self . flags & ( 1 << FlagV1 :: Alternate as u32 ) != 0
1677
+ }
1672
1678
1673
1679
/// Determines if the `0` flag was specified.
1674
1680
///
@@ -1691,15 +1697,19 @@ impl<'a> Formatter<'a> {
1691
1697
/// assert_eq!(&format!("{:04}", Foo(23)), "23");
1692
1698
/// ```
1693
1699
#[ stable( feature = "fmt_flags" , since = "1.5.0" ) ]
1694
- pub fn sign_aware_zero_pad ( & self ) -> bool {
1700
+ pub const fn sign_aware_zero_pad ( & self ) -> bool {
1695
1701
self . flags & ( 1 << FlagV1 :: SignAwareZeroPad as u32 ) != 0
1696
1702
}
1697
1703
1698
1704
// FIXME: Decide what public API we want for these two flags.
1699
1705
// https://github.com/rust-lang/rust/issues/48584
1700
- fn debug_lower_hex ( & self ) -> bool { self . flags & ( 1 << FlagV1 :: DebugLowerHex as u32 ) != 0 }
1706
+ const fn debug_lower_hex ( & self ) -> bool {
1707
+ self . flags & ( 1 << FlagV1 :: DebugLowerHex as u32 ) != 0
1708
+ }
1701
1709
1702
- fn debug_upper_hex ( & self ) -> bool { self . flags & ( 1 << FlagV1 :: DebugUpperHex as u32 ) != 0 }
1710
+ const fn debug_upper_hex ( & self ) -> bool {
1711
+ self . flags & ( 1 << FlagV1 :: DebugUpperHex as u32 ) != 0
1712
+ }
1703
1713
1704
1714
/// Creates a [`DebugStruct`] builder designed to assist with creation of
1705
1715
/// [`fmt::Debug`] implementations for structs.
0 commit comments