#[non_exhaustive]pub struct PathType {
pub path: Path,
pub lifetimes: Vec<Lifetime>,
}
Expand description
A named type that is just a path, e.g. std::borrow::Cow<'a, T>
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.path: Path
§lifetimes: Vec<Lifetime>
Implementations§
source§impl PathType
impl PathType
pub fn to_syn(&self) -> TypePath
pub fn new(path: Path) -> Self
sourcepub fn extract_self_type(strct: &ItemStruct) -> Self
pub fn extract_self_type(strct: &ItemStruct) -> Self
Get the Self
type from a struct declaration.
Consider the following struct declaration:
struct RefList<'a> {
data: &'a i32,
next: Option<Box<Self>>,
}
When determining what type Self
is in the next
field, we would have to call
this method on the syn::ItemStruct
that represents this struct declaration.
This method would then return a PathType
representing RefList<'a>
, so we
know that’s what Self
should refer to.
The reason this function exists though is so when we convert the fields’ types
to PathType
s, we don’t panic. We don’t actually need to write the struct’s
field types expanded in the macro, so this function is more for correctness,
sourcepub fn resolve_with_path<'a>(
&self,
in_path: &Path,
env: &'a Env,
) -> (Path, &'a CustomType)
pub fn resolve_with_path<'a>( &self, in_path: &Path, env: &'a Env, ) -> (Path, &'a CustomType)
If this is a TypeName::Named
, grab the CustomType
it points to from
the env
, which contains all CustomType
s across all FFI modules.
Also returns the path the CustomType is in (useful for resolving fields)
sourcepub fn resolve<'a>(&self, in_path: &Path, env: &'a Env) -> &'a CustomType
pub fn resolve<'a>(&self, in_path: &Path, env: &'a Env) -> &'a CustomType
If this is a TypeName::Named
, grab the CustomType
it points to from
the env
, which contains all CustomType
s across all FFI modules.
If you need to resolve struct fields later, call Self::resolve_with_path()
instead
to get the path to resolve the fields in.
Trait Implementations§
source§impl<'de> Deserialize<'de> for PathType
impl<'de> Deserialize<'de> for PathType
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PathType
impl StructuralPartialEq for PathType
Auto Trait Implementations§
impl Freeze for PathType
impl RefUnwindSafe for PathType
impl Send for PathType
impl Sync for PathType
impl Unpin for PathType
impl UnwindSafe for PathType
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)