1*da152319SLoGin #![no_std] 2*da152319SLoGin 3*da152319SLoGin /// 获取指定字段 4*da152319SLoGin /// 5*da152319SLoGin /// 当weak指针的strong count为0的时候,清除弱引用 6*da152319SLoGin #[macro_export] 7*da152319SLoGin macro_rules! get_weak_or_clear { 8*da152319SLoGin ($field:expr) => {{ 9*da152319SLoGin if let Some(x) = $field.clone() { 10*da152319SLoGin if x.strong_count() == 0 { 11*da152319SLoGin $field = None; 12*da152319SLoGin None 13*da152319SLoGin } else { 14*da152319SLoGin Some(x) 15*da152319SLoGin } 16*da152319SLoGin } else { 17*da152319SLoGin None 18*da152319SLoGin } 19*da152319SLoGin }}; 20*da152319SLoGin } 21