Ref map can make new Ref for borrowed data
- https://doc.rust-lang.org/std/cell/struct.Ref.html#method.map
Ref<TooComplexType>
를Ref<SimpleType>
으로 쪼갤때 사용된다.
use std::cell::{RefCell, Ref};
let c = RefCell::new(vec![1, 2, 3]);
let b1: Ref<Vec<u32>> = c.borrow();
let b2: Result<Ref<u32>, _> = Ref::filter_map(b1, |v| v.get(1));
assert_eq!(*b2.unwrap(), 2);