If you’ve got code that still uses the try!() macro, you can quickly and accurately upgrade it to the ? operator.
-
Create
rules.rsfile with:fn rule1<T,E,X: From<E>>(r: Result<T,E>) -> Result<T,X> { replace!(try!(r) => r?); unreachable!() } -
Then run:
cargo +nightly install rerast cargo +nightly rerast --rules_file=rules.rs --force
and poof! the macro will be gone. Rerast operates on the AST and fixes priorities of operations if necessary, so it’s much smarter and more correct than textual find’n’replace.


