pub struct CaveatDeferred<T, W: Warning> { /* private fields */ }Expand description
A value that may have associated Warnings.
This caveat is considered deferred as the warning still need to be associated with
a json::Element to become Warnings.
Even though the value has been created there may be certain caveats you should be aware of before using it.
NOTE: The deferred types are used to avoid passing json::Element references
to functions just to create Warnings.
Implementations§
Source§impl<T, W> CaveatDeferred<T, W>where
W: Warning,
impl<T, W> CaveatDeferred<T, W>where
W: Warning,
Sourcepub fn into_parts(self) -> (T, SetDeferred<W>)
pub fn into_parts(self) -> (T, SetDeferred<W>)
Return the value and any Warnings stored in the CaveatDeferred.
Sourcepub fn ignore_warnings(self) -> T
pub fn ignore_warnings(self) -> T
Return the value and drop any warnings contained within.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> CaveatDeferred<U, W>
pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> CaveatDeferred<U, W>
Map the value to another target type while retaining the warnings about the source type.
Trait Implementations§
Source§impl<T, W> Deref for CaveatDeferred<T, W>where
W: Warning,
A deferred Caveat is simply a value with associated Warnings that still need to be associated
with a json::Element.
impl<T, W> Deref for CaveatDeferred<T, W>where
W: Warning,
A deferred Caveat is simply a value with associated Warnings that still need to be associated
with a json::Element.
Providing an impl Deref makes sense for given that it’s an annotated value.
The same advice applies to both deref traits. In general, deref traits should be implemented if:
- a value of the type transparently behaves like a value of the target type;
- the implementation of the deref function is cheap; and
- users of the type will not be surprised by any deref coercion behavior.
See: https://doc.rust-lang.org/std/ops/trait.Deref.html#when-to-implement-deref-or-derefmut