#[non_exhaustive]pub struct ParseFormatter<T> { /* private fields */ }
Expand description
A naive Formatter
for types that implement FromStr
.
For types that implement std::fmt::Display
, the ParseFormatter::new
constructor creates a formatter that format’s its value using that trait.
If you would like to customize the formatting, you can use the
ParseFormatter::with_format_fn
constructor, and pass your own formatting
function.
Implementations§
§impl<T> ParseFormatter<T>where
T: Display,
impl<T> ParseFormatter<T>where T: Display,
pub fn new() -> ParseFormatter<T>
pub fn new() -> ParseFormatter<T>
Create a new ParseFormatter
.
§impl<T> ParseFormatter<T>
impl<T> ParseFormatter<T>
pub fn with_format_fn(f: impl Fn(&T) -> String + 'static) -> ParseFormatter<T>
pub fn with_format_fn(f: impl Fn(&T) -> String + 'static) -> ParseFormatter<T>
Create a new ParseFormatter
using the provided formatting function.
provided function.
Trait Implementations§
§impl<T> Default for ParseFormatter<T>where
T: Display,
impl<T> Default for ParseFormatter<T>where T: Display,
§fn default() -> ParseFormatter<T>
fn default() -> ParseFormatter<T>
Returns the “default value” for a type. Read more
§impl<T> Formatter<T> for ParseFormatter<T>where
T: FromStr,
<T as FromStr>::Err: Error + 'static,
impl<T> Formatter<T> for ParseFormatter<T>where T: FromStr, <T as FromStr>::Err: Error + 'static,
§fn validate_partial_input(&self, input: &str, _sel: &Selection) -> Validation
fn validate_partial_input(&self, input: &str, _sel: &Selection) -> Validation
Determine whether the newly edited text is valid for this value type. Read more
§fn value(&self, input: &str) -> Result<T, ValidationError>
fn value(&self, input: &str) -> Result<T, ValidationError>
The value represented by the input, or an error if the input is invalid. Read more
§fn format_for_editing(&self, value: &T) -> String
fn format_for_editing(&self, value: &T) -> String
Return the string representation of this value, to be used during editing. Read more
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ParseFormatter<T>
impl<T> !Send for ParseFormatter<T>
impl<T> !Sync for ParseFormatter<T>
impl<T> Unpin for ParseFormatter<T>
impl<T> !UnwindSafe for ParseFormatter<T>
Blanket Implementations§
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.