1. 访问模块成员:
mod utils { pub fn do_something() { /* ... */ } } let result = utils::do_something();
2. 访问关联函数或静态方法:
struct MyStruct; impl MyStruct { fn new() -> Self { MyStruct } } let instance = MyStruct::new();
3. 访问 trait 的关联类型或关联常量
trait MyTrait { type Output; const VALUE: u32 = 42; } impl MyTrait for i32 { type Output = String; } let value = <i32 as MyTrait>::VALUE;
4. 指定泛型类型参数
fn test3<T: AsRef<str>>(s: T) -> T { s } let result = test3::<&str>("hello");