pub struct TyCon(/* private fields */);Expand description
A type constructor — the name a concrete type is built from.
A TyCon is an opaque 32-bit tag that the consumer assigns meaning to. This
crate stores and compares constructors but never interprets them, so a language
front-end is free to map its own primitives and type formers onto whatever tags
it likes:
use type_lang::TyCon;
const INT: TyCon = TyCon::new(0);
const BOOL: TyCon = TyCon::new(1);
const FUNCTION: TyCon = TyCon::new(2);
const LIST: TyCon = TyCon::new(3);Two constructors are the same type former when their tags are equal, so keeping
the tag assignment stable across a compilation is the caller’s responsibility —
a const table, as above, is the usual way.
Implementations§
Source§impl TyCon
impl TyCon
Sourcepub const fn new(tag: u32) -> Self
pub const fn new(tag: u32) -> Self
Creates a constructor from a tag.
The tag identifies the type former; the caller chooses the numbering and is responsible for keeping it consistent. Equal tags are treated as the same constructor during unification.
§Examples
use type_lang::TyCon;
let int = TyCon::new(0);
assert_eq!(int.to_u32(), 0);Trait Implementations§
impl Copy for TyCon
Source§impl<'de> Deserialize<'de> for TyCon
impl<'de> Deserialize<'de> for TyCon
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TyCon
Source§impl Ord for TyCon
impl Ord for TyCon
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for TyCon
impl PartialOrd for TyCon
impl StructuralPartialEq for TyCon
Auto Trait Implementations§
impl Freeze for TyCon
impl RefUnwindSafe for TyCon
impl Send for TyCon
impl Sync for TyCon
impl Unpin for TyCon
impl UnsafeUnpin for TyCon
impl UnwindSafe for TyCon
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
Mutably borrows from an owned value. Read more