pub struct StdImplCache { /* private fields */ }Expand description
Cache of known trait implementations for standard library types.
This is a static cache that knows which primitives and std types implement common traits like Clone, Default, Debug, etc.
Implementations§
Source§impl StdImplCache
impl StdImplCache
Sourcepub fn has_impl(&self, type_name: &str, trait_name: &str) -> bool
pub fn has_impl(&self, type_name: &str, trait_name: &str) -> bool
Check if a type implements a trait.
Sourcepub fn is_checkable_derive(&self, trait_name: &str) -> bool
pub fn is_checkable_derive(&self, trait_name: &str) -> bool
Check whether trait_name is a std-derivable trait whose impl
relationships this cache can authoritatively answer.
Only the nine traits that #[derive(...)] can expand to from std
(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd,
Ord, Hash) are checkable. Proc-macro derives such as
serde::Serialize / serde::Deserialize / thiserror::Error /
clap::Subcommand generate impls for std types that cannot be
enumerated statically, so asking has_impl("String", "Serialize")
would return a false “missing”. Such derives must be skipped, not
reported as a precheck failure.
Sourcepub fn is_primitive(&self, type_name: &str) -> bool
pub fn is_primitive(&self, type_name: &str) -> bool
Check if a type is a known primitive.
Sourcepub fn is_std_container(&self, type_name: &str) -> bool
pub fn is_std_container(&self, type_name: &str) -> bool
Check if a type is a known std container.
Sourcepub fn traits_for(&self, type_name: &str) -> Vec<&'static str>
pub fn traits_for(&self, type_name: &str) -> Vec<&'static str>
Get all traits a type is known to implement.
Trait Implementations§
Source§impl Clone for StdImplCache
impl Clone for StdImplCache
Source§fn clone(&self) -> StdImplCache
fn clone(&self) -> StdImplCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StdImplCache
impl Debug for StdImplCache
Auto Trait Implementations§
impl Freeze for StdImplCache
impl RefUnwindSafe for StdImplCache
impl Send for StdImplCache
impl Sync for StdImplCache
impl Unpin for StdImplCache
impl UnsafeUnpin for StdImplCache
impl UnwindSafe for StdImplCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more