Re:Comparison between Rust and D
by sixbrx on Saturday June 25, 2016 @10:16AM
(#11976374)
Very useful indeed when you want a canonical or corrected (or otherwise "improved") version of a value and want to make sure that the original can't accidentally be used in what follows (which can be a hard to detect bug).
[ Parent
| on HN ]
Yes, a common refinement pattern in code is (pseudocode):
def fn(object):
let object = predicate(object) ? modify(object) : error();
// do something with the refined object
Or something along those lines.