@@ -25,18 +25,19 @@ mod float;
25
25
mod num;
26
26
mod builders;
27
27
28
- #[ unstable ( feature = "fmt_flags_align" , issue = "27726 " ) ]
28
+ #[ stable ( feature = "fmt_flags_align" , since = "1.28.0 " ) ]
29
29
/// Possible alignments returned by `Formatter::align`
30
30
#[ derive( Debug ) ]
31
31
pub enum Alignment {
32
+ #[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
32
33
/// Indication that contents should be left-aligned.
33
34
Left ,
35
+ #[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
34
36
/// Indication that contents should be right-aligned.
35
37
Right ,
38
+ #[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
36
39
/// Indication that contents should be center-aligned.
37
40
Center ,
38
- /// No alignment was requested.
39
- Unknown ,
40
41
}
41
42
42
43
#[ stable( feature = "debug_builders" , since = "1.2.0" ) ]
@@ -1433,8 +1434,6 @@ impl<'a> Formatter<'a> {
1433
1434
/// # Examples
1434
1435
///
1435
1436
/// ```
1436
- /// #![feature(fmt_flags_align)]
1437
- ///
1438
1437
/// extern crate core;
1439
1438
///
1440
1439
/// use std::fmt;
@@ -1444,11 +1443,14 @@ impl<'a> Formatter<'a> {
1444
1443
///
1445
1444
/// impl fmt::Display for Foo {
1446
1445
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1447
- /// let s = match formatter.align() {
1448
- /// Alignment::Left => "left",
1449
- /// Alignment::Right => "right",
1450
- /// Alignment::Center => "center",
1451
- /// Alignment::Unknown => "into the void",
1446
+ /// let s = if let Some(s) = formatter.align() {
1447
+ /// match s {
1448
+ /// Alignment::Left => "left",
1449
+ /// Alignment::Right => "right",
1450
+ /// Alignment::Center => "center",
1451
+ /// }
1452
+ /// } else {
1453
+ /// "into the void"
1452
1454
/// };
1453
1455
/// write!(formatter, "{}", s)
1454
1456
/// }
@@ -1461,14 +1463,13 @@ impl<'a> Formatter<'a> {
1461
1463
/// assert_eq!(&format!("{}", Foo), "into the void");
1462
1464
/// }
1463
1465
/// ```
1464
- #[ unstable( feature = "fmt_flags_align" , reason = "method was just created" ,
1465
- issue = "27726" ) ]
1466
- pub fn align ( & self ) -> Alignment {
1466
+ #[ stable( feature = "fmt_flags_align" , since = "1.28.0" ) ]
1467
+ pub fn align ( & self ) -> Option < Alignment > {
1467
1468
match self . align {
1468
- rt:: v1:: Alignment :: Left => Alignment :: Left ,
1469
- rt:: v1:: Alignment :: Right => Alignment :: Right ,
1470
- rt:: v1:: Alignment :: Center => Alignment :: Center ,
1471
- rt:: v1:: Alignment :: Unknown => Alignment :: Unknown ,
1469
+ rt:: v1:: Alignment :: Left => Some ( Alignment :: Left ) ,
1470
+ rt:: v1:: Alignment :: Right => Some ( Alignment :: Right ) ,
1471
+ rt:: v1:: Alignment :: Center => Some ( Alignment :: Center ) ,
1472
+ rt:: v1:: Alignment :: Unknown => None ,
1472
1473
}
1473
1474
}
1474
1475
0 commit comments