Struct core::fmt::rt::Argument

source ·
pub struct Argument<'a> {
    value: &'a Opaque,
    formatter: fn(_: &Opaque, _: &mut Formatter<'_>) -> Result,
}
🔬This is a nightly-only experimental API. (fmt_internals)
Expand description

This struct represents the generic “argument” which is taken by format_args!(). It contains a function to format the given value. At compile time it is ensured that the function and the value have the correct types, and then this struct is used to canonicalize arguments to one type.

Argument is essentially an optimized partially applied formatting function, equivalent to exists T.(&T, fn(&T, &mut Formatter<'_>) -> Result.

Fields§

§value: &'a Opaque
🔬This is a nightly-only experimental API. (fmt_internals)
§formatter: fn(_: &Opaque, _: &mut Formatter<'_>) -> Result
🔬This is a nightly-only experimental API. (fmt_internals)

Implementations§

source§

impl<'a> Argument<'a>

source

fn new<'b, T>( x: &'b T, f: fn(_: &T, _: &mut Formatter<'_>) -> Result ) -> Argument<'b>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_display<'b, T: Display>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_debug<'b, T: Debug>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_octal<'b, T: Octal>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_lower_hex<'b, T: LowerHex>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_upper_hex<'b, T: UpperHex>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_pointer<'b, T: Pointer>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_binary<'b, T: Binary>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_lower_exp<'b, T: LowerExp>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn new_upper_exp<'b, T: UpperExp>(x: &'b T) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn from_usize(x: &usize) -> Argument<'_>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub(super) fn fmt(&self, f: &mut Formatter<'_>) -> Result

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub(super) fn as_usize(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (fmt_internals)
source

pub fn none() -> [Self; 0]

🔬This is a nightly-only experimental API. (fmt_internals)

Used by format_args when all arguments are gone after inlining, when using &[] would incorrectly allow for a bigger lifetime.

This fails without format argument inlining, and that shouldn’t be different when the argument is inlined:

let f = format_args!("{}", "a");
println!("{f}");
Run

Trait Implementations§

source§

impl<'a> Clone for Argument<'a>

source§

fn clone(&self) -> Argument<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Copy for Argument<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Argument<'a>

§

impl<'a> !RefUnwindSafe for Argument<'a>

§

impl<'a> !Send for Argument<'a>

§

impl<'a> !Sync for Argument<'a>

§

impl<'a> Unpin for Argument<'a>

§

impl<'a> !UnwindSafe for Argument<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> SizedTypeProperties for T

source§

const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.