Skip to content

Memory

is

Overload Description
is<T>(obj: *) -> Bool Returns true if obj is bindable to the type T

as

Overload Description
as<T>(obj: *) -> 'T Coerces obj to the type T. This does not transform the underlying data, only dynamically checks if it is safe to "trick" the type system. This is useful when dealing with the different variants of sum types.

drop

Overload Description
drop<T>(obj: @'T) -> () Deletes the contents to which obj is pointing. You cannot access the data after this and every other reference pointing to that data becomes invalid

move

Overload Description
move<T>(obj: @'T) -> 'T Moves the contents to which obj is pointing to a fresh object of type 'T. You cannot access the data after this from any reference to the previous location

swap

Overload Description
swap<T>(a: @'T, b: @'T) -> () Interchanges the contents to which a and b are pointing.

ref

Overload Description
ref<T>(obj: 'T) -> &'T Creates a reference to obj

mut

Overload Description
mut<T>(obj: 'T) -> @'T Creates a mutable reference to obj

deref

Overload Description
mut<T>(obj: &'T) -> 'T Copies the contents to which obj is pointing
mut<T>(obj: @'T) -> 'T

demut

Overload Description
mut<T>(obj: @'T) -> &'T Creates a reference to obj from a mutable reference

fwd

Overload Description
fwd<T>(obj: *) -> 'T Takes obj and tries to convert it to the type T:
  • If the data's type and T are the same, then the object is returned as is
  • If the object is a mutable reference and T is a value, the function will do the same as move
  • If the object is a reference and T is a value, the function will do the same as deref
  • If obj is a reference and T is a mutable reference, the function will do the same as demut
This function is useful when creating generic code for getting around references.

cfwd

Overload Description
cfwd<T>(obj: *) -> 'T The same as fwd, but clones objects instead of moving them