用法
pub fn get_mut(&mut self) -> &mut T
返回对基础数据的可变引用。
这个调用可变地借用了UnsafeCell
(在编译时),这保证了我们拥有唯一的引用。
例子
use std::cell::UnsafeCell;
let mut c = UnsafeCell::new(5);
*c.get_mut() += 1;
assert_eq!(*c.get_mut(), 6);
相关用法
- Rust core::cell::UnsafeCell.get用法及代码示例
- Rust core::cell::UnsafeCell.raw_get用法及代码示例
- Rust core::cell::UnsafeCell.new用法及代码示例
- Rust core::cell::UnsafeCell用法及代码示例
- Rust core::cell::Cell.as_slice_of_cells用法及代码示例
- Rust core::cell::Cell.swap用法及代码示例
- Rust core::cell::RefCell.replace_with用法及代码示例
- Rust core::cell::RefCell.try_borrow用法及代码示例
- Rust core::cell::RefCell.borrow用法及代码示例
- Rust core::cell::RefMut.filter_map用法及代码示例
- Rust core::cell::Cell.get_mut用法及代码示例
- Rust core::cell::Cell.take用法及代码示例
- Rust core::cell::Ref.map_split用法及代码示例
- Rust core::cell::Cell.replace用法及代码示例
- Rust core::cell::Cell用法及代码示例
- Rust core::cell::Ref.filter_map用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 core::cell::UnsafeCell.get_mut。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。