logoalt Hacker News

kibwen • yesterday at 10:06 PM • 1 reply • view on HN

Proposal here: https://github.com/rust-lang/libs-team/issues/820

Looks like part of the motivation was for things with long names like `some_struct_a.some_field_b.some_subfield_c`, where needing to name the field twice would have pushed people to using `^= true` instead, which is a bit more roundabout to decipher and risks people forgetting the idiom and writing `^= false` by accident. Not necessarily the most useful API, but not unmotivated and harmless to add.


Replies

ammar_az • yesterday at 10:40 PM

I think `toggle()` is also much better for readability as `^=true`