File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,13 @@ impl VisitMut for RewriteVisitor {
100100 #[ allow( unused_imports) ]
101101 use cast_checks:: MaybeTryIntoFallback ;
102102
103+ // smoelius: It is tempting to want to use `TryFrom` here rather than `TryInto`.
104+ // However, there are at least two reasons to prefer `TryInto`:
105+ // - Practical: Though developers should not implement `TryInto` directly, they may.
106+ // Thus, using `TryInto` can catch more cases.
107+ // - Aesthetic: The value `#operand` is wrapped in a `MaybeTryInto`, which becomes
108+ // the `self` argument to `maybe_try_into`. Thus, `TryInto` better resembles the
109+ // underlying implementation.
103110 #[ allow( unused_parens, clippy:: double_parens) ]
104111 if let Some ( result) = cast_checks:: MaybeTryInto :: <_, #ty >:: new( #operand ) . maybe_try_into( ) {
105112 result. expect( #msg )
You can’t perform that action at this time.
0 commit comments