Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / reference v0.1.0-demo.2

    Copy, move, and borrow rules

    ValuePassing by value
    Numbers and booleansCopy
    String and Vec with cloneable elementsIndependent copy of contents
    Box, File, or a type containing a move-only componentOwnership transfer; original becomes unavailable

    Structs, enums, and tuples follow their components. One move-only component makes the entire value move-only. A function return transfers its result to the caller.

    &T is shared, &mut T is mutable, and *reference reads the target. A mutable borrow requires a let mut owner. Explicit reference creation and parameters require explc.

    While a shared reference remains in use, the original cannot change or move. While a mutable reference remains in use, another reference or the original cannot access that value. Restrictions end after the reference’s last use. References cannot be returned or stored in struct fields. Temporaries cannot be borrowed directly.

    Owned values are released on block exit, including return, break, continue, and ?. Open Files close automatically. Panic and runtime errors terminate without normal cleanup.

    Learn more: Copies, moves, and references