[][src]Function tao_of_rust::ch03::type_cast::manual_deref

pub fn manual_deref()

类型转换:手动解引用(For SmartPointer)

Base usage: Rc&str 都实现了clone

use std::rc::Rc;

let x = Rc::new("hello");
let y = x.clone();  // Rc<&str>
let z = (*x).clone();   // &strRun

Base usage: match匹配里需要手动解引用

将match &x改为以下5种形式任意一种即可:

    let x = "hello".to_string();
    match &x {
        "hello" => {println!("hello")},
        _ => {}
    }Run