Tut i Rustit Tabela e permbajtjeve

Moduli I Brendashkruar

Një nën-modul mund të vendoset direkt brenda kodit të një moduli (inline).

Një përdorim shumë i zakonshëm i moduleve inline është krijimi i unit teste. Krijojmë një modul inline që ekziston vetëm kur Rust përdoret për testim!

// This macro removes this inline module when Rust
// is not in test mode.
#[cfg(test)]
mod tests {
    // Notice that we don't immediately get access to the
    // parent module. We must be explicit.
    use super::*;

    ... tests go here ...
}
Mascot Ferris