`

rust引用记数

    博客分类:
  • rust
 
阅读更多
fn test_ref(){
    use std::rc::Rc;
    let x = Rc::new(4);
    let y1 = x.clone();//增加强引用记数
    let y2 = x.clone();
    println!("{:?}",Rc::strong_count(&x));
    let w = Rc::downgrade(&x);//增加弱引用记数
    println!("{:?}",Rc::weak_count(&x));
    let y3 = &*x;
    println!("{}",100 - *x);
}

3
1
96
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics