#![stable(feature = "rust1", since = "1.0.0")]
-use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
-use marker::PhantomData;
-use mem;
-use num::flt2dec;
-use ops::Deref;
-use result;
-use slice;
-use str;
+use crate::cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
+use crate::marker::PhantomData;
+use crate::mem;
+use crate::num::flt2dec;
+use crate::ops::Deref;
+use crate::result;
+use crate::slice;
+use crate::str;
mod float;
mod num;
/// }
///
/// impl fmt::Display for Triangle {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "({}, {}, {})", self.a, self.b, self.c)
/// }
/// }
/// assert_eq!(&buf, "world");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- fn write_fmt(mut self: &mut Self, args: Arguments) -> Result {
+ fn write_fmt(mut self: &mut Self, args: Arguments<'_>) -> Result {
write(&mut self, args)
}
}
(**self).write_char(c)
}
- fn write_fmt(&mut self, args: Arguments) -> Result {
+ fn write_fmt(&mut self, args: Arguments<'_>) -> Result {
(**self).write_fmt(args)
}
}
}
// NB. Argument is essentially an optimized partially applied formatting function,
-// equivalent to `exists T.(&T, fn(&T, &mut Formatter) -> Result`.
+// equivalent to `exists T.(&T, fn(&T, &mut Formatter<'_>) -> Result`.
struct Void {
_priv: (),
#[doc(hidden)]
pub struct ArgumentV1<'a> {
value: &'a Void,
- formatter: fn(&Void, &mut Formatter) -> Result,
+ formatter: fn(&Void, &mut Formatter<'_>) -> Result,
}
impl<'a> ArgumentV1<'a> {
#[inline(never)]
- fn show_usize(x: &usize, f: &mut Formatter) -> Result {
+ fn show_usize(x: &usize, f: &mut Formatter<'_>) -> Result {
Display::fmt(x, f)
}
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
issue = "0")]
pub fn new<'b, T>(x: &'b T,
- f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {
+ f: fn(&T, &mut Formatter<'_>) -> Result) -> ArgumentV1<'b> {
unsafe {
ArgumentV1 {
formatter: mem::transmute(f),
#[doc(hidden)]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
issue = "0")]
- pub fn from_usize(x: &usize) -> ArgumentV1 {
+ pub fn from_usize(x: &usize) -> ArgumentV1<'_> {
ArgumentV1::new(x, ArgumentV1::show_usize)
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for Arguments<'_> {
- fn fmt(&self, fmt: &mut Formatter) -> Result {
+ fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
Display::fmt(self, fmt)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for Arguments<'_> {
- fn fmt(&self, fmt: &mut Formatter) -> Result {
+ fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
write(fmt.buf, *self)
}
}
/// }
///
/// impl fmt::Debug for Point {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y)
/// }
/// }
/// }
///
/// impl fmt::Debug for Position {
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "({:?}, {:?})", self.longitude, self.latitude)
/// }
/// }
/// format!("{:?}", Position { longitude: 1.987, latitude: 2.983, }));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// Format trait for an empty format, `{}`.
/// }
///
/// impl fmt::Display for Point {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "({}, {})", self.x, self.y)
/// }
/// }
/// }
///
/// impl fmt::Display for Position {
- /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// write!(f, "({}, {})", self.longitude, self.latitude)
/// }
/// }
/// format!("{}", Position { longitude: 1.987, latitude: 2.983, }));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `o` formatting.
/// struct Length(i32);
///
/// impl fmt::Octal for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:o}", val) // delegate to i32's implementation
pub trait Octal {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `b` formatting.
/// struct Length(i32);
///
/// impl fmt::Binary for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:b}", val) // delegate to i32's implementation
pub trait Binary {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `x` formatting.
/// struct Length(i32);
///
/// impl fmt::LowerHex for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:x}", val) // delegate to i32's implementation
pub trait LowerHex {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `X` formatting.
/// struct Length(i32);
///
/// impl fmt::UpperHex for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:X}", val) // delegate to i32's implementation
pub trait UpperHex {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `p` formatting.
/// struct Length(i32);
///
/// impl fmt::Pointer for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// // use `as` to convert to a `*const T`, which implements Pointer, which we can use
///
/// write!(f, "{:p}", self as *const Length)
pub trait Pointer {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `e` formatting.
///
/// # Examples
///
-/// Basic usage with `i32`:
+/// Basic usage with `f64`:
///
/// ```
/// let x = 42.0; // 42.0 is '4.2e1' in scientific notation
/// struct Length(i32);
///
/// impl fmt::LowerExp for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
/// write!(f, "{}e1", val / 10)
/// }
pub trait LowerExp {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// `E` formatting.
///
/// # Examples
///
-/// Basic usage with `f32`:
+/// Basic usage with `f64`:
///
/// ```
/// let x = 42.0; // 42.0 is '4.2E1' in scientific notation
/// struct Length(i32);
///
/// impl fmt::UpperExp for Length {
-/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
/// write!(f, "{}E1", val / 10)
/// }
pub trait UpperExp {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
- fn fmt(&self, f: &mut Formatter) -> Result;
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
/// The `write` function takes an output stream, and an `Arguments` struct
///
/// [`write!`]: ../../std/macro.write.html
#[stable(feature = "rust1", since = "1.0.0")]
-pub fn write(output: &mut dyn Write, args: Arguments) -> Result {
+pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
let mut formatter = Formatter {
flags: 0,
width: None,
// Writes the sign if it exists, and then the prefix if it was requested
#[inline(never)]
- fn write_prefix(f: &mut Formatter, sign: Option<char>, prefix: Option<&str>) -> Result {
+ fn write_prefix(f: &mut Formatter<'_>, sign: Option<char>, prefix: Option<&str>) -> Result {
if let Some(c) = sign {
f.buf.write_char(c)?;
}
/// Takes the formatted parts and applies the padding.
/// Assumes that the caller already has rendered the parts with required precision,
/// so that `self.precision` can be ignored.
- fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
+ fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result {
if let Some(mut width) = self.width {
// for the sign-aware zero padding, we render the sign first and
// behave as if we had no sign from the beginning.
}
}
- fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
+ fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result {
fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result {
buf.write_str(unsafe { str::from_utf8_unchecked(s) })
}
/// assert_eq!(&format!("{:0>8}", Foo(2)), "Foo 2");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- pub fn write_fmt(&mut self, fmt: Arguments) -> Result {
+ pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result {
write(self.buf, fmt)
}
self.buf.write_char(c)
}
- fn write_fmt(&mut self, args: Arguments) -> Result {
+ fn write_fmt(&mut self, args: Arguments<'_>) -> Result {
write(self.buf, args)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for Error {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Display::fmt("an error occurred when formatting an argument", f)
}
}
$(
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + $tr> $tr for &T {
- fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) }
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + $tr> $tr for &mut T {
- fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) }
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) }
}
)*
}
#[unstable(feature = "never_type", issue = "35121")]
impl Debug for ! {
- fn fmt(&self, _: &mut Formatter) -> Result {
+ fn fmt(&self, _: &mut Formatter<'_>) -> Result {
*self
}
}
#[unstable(feature = "never_type", issue = "35121")]
impl Display for ! {
- fn fmt(&self, _: &mut Formatter) -> Result {
+ fn fmt(&self, _: &mut Formatter<'_>) -> Result {
*self
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for bool {
#[inline]
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Display::fmt(self, f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for bool {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Display::fmt(if *self { "true" } else { "false" }, f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for str {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.write_char('"')?;
let mut from = 0;
for (i, c) in self.char_indices() {
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for str {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.pad(self)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for char {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.write_char('\'')?;
for c in self.escape_debug() {
f.write_char(c)?
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for char {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if f.width.is_none() && f.precision.is_none() {
f.write_char(*self)
} else {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Pointer for *const T {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
let old_width = f.width;
let old_flags = f.flags;
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Pointer for *mut T {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Pointer::fmt(&(*self as *const T), f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Pointer for &T {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Pointer::fmt(&(*self as *const T), f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Pointer for &mut T {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Pointer::fmt(&(&**self as *const T), f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Debug for *const T {
- fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(self, f) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Debug for *mut T {
- fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(self, f) }
}
macro_rules! peel {
() => ();
( $($name:ident,)+ ) => (
#[stable(feature = "rust1", since = "1.0.0")]
- impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized {
+ impl<$($name:Debug),+> Debug for ($($name,)+) where last_type!($($name,)+): ?Sized {
#[allow(non_snake_case, unused_assignments)]
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
let mut builder = f.debug_tuple("");
- let ($(ref $name,)*) = *self;
+ let ($(ref $name,)+) = *self;
$(
builder.field(&$name);
- )*
+ )+
builder.finish()
}
}
- peel! { $($name,)* }
+ peel! { $($name,)+ }
)
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Debug> Debug for [T] {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.debug_list().entries(self.iter()).finish()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for () {
#[inline]
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.pad("()")
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Debug for PhantomData<T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.pad("PhantomData")
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Copy + Debug> Debug for Cell<T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.debug_struct("Cell")
.field("value", &self.get())
.finish()
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + Debug> Debug for RefCell<T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self.try_borrow() {
Ok(borrow) => {
f.debug_struct("RefCell")
struct BorrowedPlaceholder;
impl Debug for BorrowedPlaceholder {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.write_str("<borrowed>")
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + Debug> Debug for Ref<'_, T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Debug::fmt(&**self, f)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + Debug> Debug for RefMut<'_, T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
Debug::fmt(&*(self.deref()), f)
}
}
#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<T: ?Sized + Debug> Debug for UnsafeCell<T> {
- fn fmt(&self, f: &mut Formatter) -> Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
f.pad("UnsafeCell")
}
}