Skip to content

Commit 40aed49

Browse files
committed
Stabilize fmt_flags_align
Fixes rust-lang#27726
1 parent f900bcf commit 40aed49

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/liballoc/fmt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@
515515
pub use core::fmt::rt;
516516
#[stable(feature = "rust1", since = "1.0.0")]
517517
pub use core::fmt::{Formatter, Result, Write};
518+
#[stable(feature = "fmt_flags_align", since = "1.27.0")]
519+
pub use core::fmt::Alignment;
518520
#[stable(feature = "rust1", since = "1.0.0")]
519521
pub use core::fmt::{Binary, Octal};
520522
#[stable(feature = "rust1", since = "1.0.0")]

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#![feature(custom_attribute)]
9696
#![feature(dropck_eyepatch)]
9797
#![feature(exact_size_is_empty)]
98+
#![feature(fmt_flags_align)]
9899
#![feature(fmt_internals)]
99100
#![feature(fn_must_use)]
100101
#![feature(from_ref)]

src/libcore/fmt/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ mod builders;
2727

2828
#[unstable(feature = "fmt_flags_align", issue = "27726")]
2929
/// Possible alignments returned by `Formatter::align`
30-
#[derive(Debug)]
30+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
3131
pub enum Alignment {
3232
/// Indication that contents should be left-aligned.
3333
Left,
3434
/// Indication that contents should be right-aligned.
3535
Right,
3636
/// Indication that contents should be center-aligned.
37-
Center,
38-
/// No alignment was requested.
39-
Unknown,
37+
Center
4038
}
4139

4240
#[stable(feature = "debug_builders", since = "1.2.0")]
@@ -1385,14 +1383,13 @@ impl<'a> Formatter<'a> {
13851383
pub fn fill(&self) -> char { self.fill }
13861384

13871385
/// Flag indicating what form of alignment was requested
1388-
#[unstable(feature = "fmt_flags_align", reason = "method was just created",
1389-
issue = "27726")]
1390-
pub fn align(&self) -> Alignment {
1386+
#[stable(feature = "fmt_flags_align", since = "1.27.0")]
1387+
pub fn align(&self) -> Option<Alignment> {
13911388
match self.align {
1392-
rt::v1::Alignment::Left => Alignment::Left,
1393-
rt::v1::Alignment::Right => Alignment::Right,
1394-
rt::v1::Alignment::Center => Alignment::Center,
1395-
rt::v1::Alignment::Unknown => Alignment::Unknown,
1389+
rt::v1::Alignment::Left => Some(Alignment::Left),
1390+
rt::v1::Alignment::Right => Some(Alignment::Right),
1391+
rt::v1::Alignment::Center => Some(Alignment::Center),
1392+
rt::v1::Alignment::Unknown => None,
13961393
}
13971394
}
13981395

0 commit comments

Comments
 (0)