pub struct ConversionError<T> { /* private fields */ }
Expand description
Error with value before conversion.
Implementations§
Source§impl<T> ConversionError<T>
impl<T> ConversionError<T>
Sourcepub fn error(&self) -> Error
pub fn error(&self) -> Error
Returns the inner (validation) error.
§Examples
// `rfc3339::FullTimeString` is only available when `alloc` feature is enabled.
#![cfg(feature = "alloc")]
use std::convert::TryFrom;
use datetime_string::{Error, rfc3339::FullTimeString};
let conv_err = FullTimeString::try_from("invalid time".to_owned()).unwrap_err();
let _: Error = conv_err.error();
Sourcepub fn value(&self) -> &T
pub fn value(&self) -> &T
Returns a reference to the value, which is failed to convert.
§Examples
// `rfc3339::FullTimeString` is only available when `alloc` feature is enabled.
#![cfg(feature = "alloc")]
use std::convert::TryFrom;
use datetime_string::{Error, rfc3339::FullTimeString};
let conv_err = FullTimeString::try_from("invalid time".to_owned()).unwrap_err();
let source_val: &String = conv_err.value();
assert_eq!(source_val, "invalid time");
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Returns the value, which is failed to convert.
§Examples
// `rfc3339::FullTimeString` is only available when `alloc` feature is enabled.
#![cfg(feature = "alloc")]
use std::convert::TryFrom;
use datetime_string::{Error, rfc3339::FullTimeString};
let conv_err = FullTimeString::try_from("invalid time".to_owned()).unwrap_err();
let source_val: String = conv_err.into_value();
assert_eq!(source_val, "invalid time");
Trait Implementations§
Source§impl<T: Clone> Clone for ConversionError<T>
impl<T: Clone> Clone for ConversionError<T>
Source§fn clone(&self) -> ConversionError<T>
fn clone(&self) -> ConversionError<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for ConversionError<T>
impl<T: Debug> Debug for ConversionError<T>
Source§impl<T: Debug> Display for ConversionError<T>
impl<T: Debug> Display for ConversionError<T>
Source§impl<T: Debug> Error for ConversionError<T>
Available on crate feature std
only.
impl<T: Debug> Error for ConversionError<T>
Available on crate feature
std
only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl<T> Freeze for ConversionError<T>where
T: Freeze,
impl<T> RefUnwindSafe for ConversionError<T>where
T: RefUnwindSafe,
impl<T> Send for ConversionError<T>where
T: Send,
impl<T> Sync for ConversionError<T>where
T: Sync,
impl<T> Unpin for ConversionError<T>where
T: Unpin,
impl<T> UnwindSafe for ConversionError<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more