Closed charliethomson closed 4 years ago
IMHO I don't think it is worth it, we could not utilize assert_eq!
with this. Most of the cases, we could just cell.take()
but we didn't since we want to keep the output, we could do that as well.
let cell = Cell::from("Hello World!".to_owned());
let s = cell.take();
assert!(s.contains("Hello"));
cell.set(s);
assert_eq!(cell.take(), "Hello World!");
It could be:
let cell = Cell::from("Hello World!".to_owned());
let s = cell.take();
assert!(s.contains("Hello"));
assert_eq!(s, "Hello World!");
assert_eq!(cell.take(), ""); // not tested
@charliethomson Can we close this? I don't see much benefit this helper provides, it helps only a bit but makes it not ergonomic (_map
).
@charliethomson I am sorry about it. Thanks for the patch. :D
This adds a trait
CellMap<T>
that allows you to test a predicate on the internal value of aCell<T>
Examples
This also changes a few tests to use this interface,
test_condputs
andtest_number