ref_wrapper
Wrapper of dynamically borrowed data.
The author of this crate is not good at English.
Forgive me if the document is hard to read.
This crate have mainly below items.
Name | Summary |
---|---|
RefWrap |
Wrapper of Ref . |
RefWrapMut |
Wrapper of RefMut . |
RefIter |
Iterator version of RefWrap . |
RefIterMut |
Iterator version of RefWrapMut . |
Examples
Normal use case.
let src = new;
let target = new;
assert_eq!;
;
Iterator use case.
let src = new;
let iter = new;
assert_eq!;
Frequent careless mistakes
When using synonyms for iterators, be careful not to specify the wrong type parameter.
For example, the result type of Vec<T>::iter(&self)
method is Iter<'a, T>
, which
when wrapped becomes RefIter<'a, &T>
. Note the change from T
to &T
. The reason
for this is that the type Iter<'a, T>
implements the trait Iterator<Item = &'a T>
,
and the wrapping target is latter. Although somewhat cumbersome, this allows for the
case where an Iterator's Item is not a reference.
What's new.
Ver 0.1.2
- Some internal function is inlined.