I’m not sure about toggling exactly but there are a few similar “convenience methods” I’ve wanted in the past (and some random names):
-
reset – equivalent to mem::replace(path, false). I often want to do something like while dirty.reset() {... dirty = true; ...}
-
increment – equivalent to fetch_add(1, Ordering::SeqCst) but for ordinary integers, not atomic ones
Similar to the poster here, I’ve never quite felt sufficiently motivated to make a helper library for these.