Skip to content

diff&cmp not suitable to be called as library functions. #280

Description

@gmatht

Problems with using diffutils.rs as a library:

  1. ExitCode is intended to be consumed only by the standard library ... For forwards compatibility with potentially unusual targets, this type currently does not provide Eq, Hash, or access to the raw value. ... so it seems library callers (such as myself) would prefer an i32.
  2. The exit(2) is worrying for library callers who don't want to be suddenly killed.

I got the hy3 model to create a fix for this for me. But it lumped it all into one big commit: gmatht@4bdd521

Should I make a pull request including two commits:

  1. Replace the ExitCode/exit() convention with i32 returns, everywhere except at the very top main function.
  2. Add Tests that ensure errors return an appropriate i32 instead of aborting the whole process.

Also should 1./2. be split into updating diff.rs and updating cmp.rs, resulting in 4 commits? If so, main should also should still be updated in each commit so e.g. it doesn't break the build.

Do you prefer that the test or the fix be commited first?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions