Skip to content

Conversation

@natecook1000
Copy link
Member

@natecook1000 natecook1000 commented May 21, 2020

Description

This changes ParsableCommand's run requirement to be mutating. This allows for things like in-place sorting or filtering of arguments without making a mutable copy.

This change supersedes #33.

Detailed Design

The only change here is the switch to mutating for the run() method.

protocol ParsableCommand: ParsableArguments {
    // other requirements

    /// ...
    mutating func run() throws
}

Documentation Plan

We didn't previously mention the non-mutatingness of run(), so that doesn't require a change. All code samples have been updated to implement the new requirement.

Test Plan

All existing tests pass with the change.

Source Impact

This will require code changes for every command that implements a run() method, since a non-mutating run() won't properly satisfy the new requirement. Since ParsableCommand provides a default implementation for run(), there unfortunately won't be any indication of this change at compile time.

Apparently this is in fact source-compatible with existing code. Clients can add mutating as they want, but existing non-mutating run() methods will be called correctly. 🎉

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit aad1ac0 into master Jun 2, 2020
@natecook1000 natecook1000 deleted the nate/mutating_run branch June 2, 2020 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants