module-concept

Rust Import aliases

Rename an imported binding to avoid collisions or clarify a role. The original item keeps its name and type; only the local binding changes. Expected result (not executed): 7 Why: PriceTable is a local name for BTreeMap. Common mistake: Expecting an import alias to create a distinct type.

Formal Syntax & Structure

rust syntaxrust
use path::Item as LocalName;

Working Example

Example Snippetrust
use std::collections::BTreeMap as PriceTable;fn main() {    let table = PriceTable::from([("tea", 7)]);    println!("{}", table["tea"]);}
Rust Reference