Rust compute diff on two files


I have this weird situation where:

  1. If I copy/paste an example, it works.

  2. My manually typed in code does not work.

  3. I went through the official-example and my-typed-version and I can’t find the difference.

  4. Is there something better than diff for computing the diff between two *.rs files ?


PS: I tracked down the error. I wrote t.2 instead of t.3 … which caused a cryptic example on a COMPLETELY DIFFERENT LINE. :slight_smile:

Anyway, I’m still looking for a tool that can do a “semantic diff” *ignoring comments, whitespace, etc …) so it’s easier to figure out where manually typed in code differs from sample code.


At least git diff and GNU diff can ignore various kinds of whitespace, including all of it with the -w switch. GNU diff can also ignore changes on lines matching a regex (could help with comments). Git diff can also do --word-diff to precisely locate changed words, GNU has separate wdiff for this.
That’s all not really semantic, but still could help.

1 Like

For larger projects I typically use kdiff3

1 Like