pub struct CaveatDeferred<T, K: Kind> { /* private fields */ }Expand description
A value that may have associated warning Kinds.
This caveat is considered deferred as the warning kinds 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, K> CaveatDeferred<T, K>where
K: Kind,
impl<T, K> CaveatDeferred<T, K>where
K: Kind,
Sourcepub fn into_parts(self) -> (T, SetDeferred<K>)
pub fn into_parts(self) -> (T, SetDeferred<K>)
Return the value and any warning Kinds 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, K>
pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> CaveatDeferred<U, K>
Map the value to another target type while retaining the warnings about the source type.
Trait Implementations§
Source§impl<T, K> Deref for CaveatDeferred<T, K>where
K: Kind,
A deferred Caveat is simply a value with associated warning Kinds that still need to be associated
with a json::Element to become Warnings.
impl<T, K> Deref for CaveatDeferred<T, K>where
K: Kind,
A deferred Caveat is simply a value with associated warning Kinds that still need to be associated
with a json::Element to become Warnings.
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