pub struct ConstAssertionVisitor<'a> {
pub db: &'a dyn TypeDatabase,
pub guard: RecursionGuard<TypeId>,
}Expand description
Visitor that applies as const transformation to a type.
This visitor implements the const assertion logic from TypeScript:
- Literals: Preserved as-is
- Arrays: Converted to readonly tuples
- Tuples: Marked readonly, elements recursively const-asserted
- Objects: All properties marked readonly, recursively const-asserted
- Other types: Preserved as-is (any, unknown, primitives, etc.)
Fields§
§db: &'a dyn TypeDatabaseThe type database/interner.
guard: RecursionGuard<TypeId>Unified recursion guard for cycle detection.
Implementations§
Source§impl<'a> ConstAssertionVisitor<'a>
impl<'a> ConstAssertionVisitor<'a>
Sourcepub fn new(db: &'a dyn TypeDatabase) -> Self
pub fn new(db: &'a dyn TypeDatabase) -> Self
Create a new ConstAssertionVisitor.
Sourcepub fn apply_const_assertion(&mut self, type_id: TypeId) -> TypeId
pub fn apply_const_assertion(&mut self, type_id: TypeId) -> TypeId
Apply const assertion to a type, returning the transformed type ID.
Auto Trait Implementations§
impl<'a> Freeze for ConstAssertionVisitor<'a>
impl<'a> !RefUnwindSafe for ConstAssertionVisitor<'a>
impl<'a> !Send for ConstAssertionVisitor<'a>
impl<'a> !Sync for ConstAssertionVisitor<'a>
impl<'a> Unpin for ConstAssertionVisitor<'a>
impl<'a> UnsafeUnpin for ConstAssertionVisitor<'a>
impl<'a> !UnwindSafe for ConstAssertionVisitor<'a>
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