pub struct TypeId {
pub name: String,
}Expand description
A nominal type’s identity: a name, and nothing else.
#[prebindgen] names live in one flat namespace — a duplicate is a
ParseError — so the name is the whole address. It
deliberately carries no crate: a reference carries a name, and the
declaring crate belongs to the declaration, reachable by looking the name up
among the elements. Putting the use site’s crate here would make the same
type compare unequal to itself across two source crates.
A name rather than a syn::Path on purpose: an identity kept as syntax
makes every consumer take a path apart to learn what a type is, which is the
re-classification issue #211 exists to stop.
Fields§
§name: StringThe path as written, minus any generic arguments — Foo,
foreign::Option. Normalized, so a reducible std or source-module path
has already collapsed to its final segment.
A String, so a raw identifier is stored the way Ident prints
it — r#type, hashes and all. Recover it with Self::ident rather
than Ident::new, which rejects that spelling.
Implementations§
Source§impl TypeId
impl TypeId
Sourcepub fn ident(&self) -> Option<Ident>
pub fn ident(&self) -> Option<Ident>
This name as an identifier, raw forms included.
Ident::new("r#type", …) panics — it takes a bare name, not a
spelling — so a consumer rebuilding an ident from Self::name has to
parse rather than construct. Here so that recovery is written once: the
caller that gets it wrong does not fail until a source happens to use a
keyword, which is exactly the kind of bug that ships.
None for a name that is not a single identifier at all (a
path-qualified foreign::Option), which is the same answer
bare_path_ident gave for one.
Trait Implementations§
impl Eq for TypeId
impl StructuralPartialEq for TypeId
Auto Trait Implementations§
impl Freeze for TypeId
impl RefUnwindSafe for TypeId
impl Send for TypeId
impl Sync for TypeId
impl Unpin for TypeId
impl UnsafeUnpin for TypeId
impl UnwindSafe for TypeId
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