Struct strfmt::Formatter

source ·
pub struct Formatter<'a, 'b> {
    pub key: &'a str,
    /* private fields */
}

Fields§

§key: &'a str

Implementations§

source§

impl<'a, 'b> Formatter<'a, 'b>

implement formatting of strings

source

pub fn str(&mut self, s: &str) -> Result<()>

format the given string onto the buffer

source

pub fn str_unchecked(&mut self, s: &str) -> Result<()>

UNSTABLE+UNTESTED: do not use in your own code (yet) Do the same as str but do not check the format string for errors. This gives a moderate performance boost. This isn’t exactly unsafe, it just ends up ignoring extranious format specifiers For example, {x:<-#10} should technically be formatting an int, but ignoring the integer specific formatting is probably not the end of the world This can also be used by the u64 etc methods to finish their formatting while still using the str formatter for width and alignment

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn from_str(s: &'a str, buff: &'b mut String) -> Result<Formatter<'a, 'b>>

create Formatter from format string

source

pub fn skip(self) -> Result<()>

call this to re-write the original format string verbatum back to the output

source

pub fn fill(&self) -> char

fill getter

source

pub fn align(&self) -> Alignment

align getter

source

pub fn set_default_align(&mut self, align: Alignment)

source

pub fn width(&self) -> Option<usize>

width getter

source

pub fn thousands(&self) -> bool

thousands getter

source

pub fn precision(&self) -> Option<usize>

precision getter

source

pub fn set_precision(&mut self, precision: Option<usize>)

set precision to None, used for formatting int, float, etc

source

pub fn sign(&self) -> Sign

sign getter

source

pub fn sign_plus(&self) -> bool

sign plus getter here because it is in fmt::Formatter

source

pub fn sign_minus(&self) -> bool

sign minus getter here because it is in fmt::Formatter

source

pub fn alternate(&self) -> bool

alternate getter

source

pub fn ty(&self) -> Option<char>

type getter

source

pub fn is_int_type(&self) -> bool

UNSTABLE: in the future, this may return true if all validty checks for a float return true return true if ty is valid for formatting integers

source

pub fn is_float_type(&self) -> bool

UNSTABLE: in the future, this may return true if all validty checks for a float return true return true if ty is valid for formatting floats

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn u8(&mut self, x: u8) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn i8(&mut self, x: i8) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn u16(&mut self, x: u16) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn i16(&mut self, x: i16) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn u32(&mut self, x: u32) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn i32(&mut self, x: i32) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn u64(&mut self, x: u64) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn i64(&mut self, x: i64) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn usize(&mut self, x: usize) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn isize(&mut self, x: isize) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn f32(&mut self, x: f32) -> Result<()>

source§

impl<'a, 'b> Formatter<'a, 'b>

source

pub fn f64(&mut self, x: f64) -> Result<()>

Trait Implementations§

source§

impl<'a, 'b> Debug for Formatter<'a, 'b>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, 'b> PartialEq<Formatter<'a, 'b>> for Formatter<'a, 'b>

source§

fn eq(&self, other: &Formatter<'a, 'b>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, 'b> Write for Formatter<'a, 'b>

source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

impl<'a, 'b> StructuralPartialEq for Formatter<'a, 'b>

Auto Trait Implementations§

§

impl<'a, 'b> RefUnwindSafe for Formatter<'a, 'b>

§

impl<'a, 'b> Send for Formatter<'a, 'b>

§

impl<'a, 'b> Sync for Formatter<'a, 'b>

§

impl<'a, 'b> Unpin for Formatter<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for Formatter<'a, 'b>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.