pub struct UnexpectedValue { /* private fields */ }
Expand description
Error caused when trying to convert JsonValue
into some wrong type value.
use tinyjson::{JsonValue, UnexpectedValue};
use std::convert::TryFrom;
let error = String::try_from(JsonValue::from(1.0)).unwrap_err();
assert!(matches!(error, UnexpectedValue{..}));
Implementations§
Trait Implementations§
Source§impl Debug for UnexpectedValue
impl Debug for UnexpectedValue
Source§impl Display for UnexpectedValue
impl Display for UnexpectedValue
Source§impl Error for UnexpectedValue
impl Error for UnexpectedValue
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()
Source§impl From<UnexpectedValue> for JsonValue
Convert this error into the value which failed to be converted.
impl From<UnexpectedValue> for JsonValue
Convert this error into the value which failed to be converted.
use tinyjson::JsonValue;
use std::convert::TryFrom;
let error = String::try_from(JsonValue::from(1.0)).unwrap_err();
assert_eq!(JsonValue::from(error), JsonValue::Number(1.0));
Source§fn from(err: UnexpectedValue) -> Self
fn from(err: UnexpectedValue) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for UnexpectedValue
impl RefUnwindSafe for UnexpectedValue
impl Send for UnexpectedValue
impl Sync for UnexpectedValue
impl Unpin for UnexpectedValue
impl UnwindSafe for UnexpectedValue
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