pub struct TypeContainer {
pub env: TypeEnv,
}
Expand description
Used for candid_derive::export_service
to generate TypeEnv
from Type
.
It performs a global rewriting of Type
to resolve:
- Duplicate type names in different modules/namespaces.
- Give different names to instantiated polymorphic types.
- Find the type name of a recursive node
Knot(TypeId)
and convert toVar
node.
There are some drawbacks of this approach:
- The type name is based on
type_name::<T>()
, whose format is unspecified and long. We use some regex to shorten the name. - Several Rust types can map to the same Candid type, and we only get to remember one name (currently we choose the shortest name). As a result, some of the type names in Rust is lost.
- Unless we do equivalence checking, recursive types can be unrolled and assigned to multiple names.
Fields§
§env: TypeEnv
Implementations§
source§impl TypeContainer
impl TypeContainer
Trait Implementations§
source§impl Default for TypeContainer
impl Default for TypeContainer
source§fn default() -> TypeContainer
fn default() -> TypeContainer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TypeContainer
impl RefUnwindSafe for TypeContainer
impl !Send for TypeContainer
impl !Sync for TypeContainer
impl Unpin for TypeContainer
impl UnwindSafe for TypeContainer
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