title: OptionSet with inverted options
body: <p>Say I have a set of options that I can pass to certain processes, for example</p>
  
  <pre><code>struct Options: OptionSet {
     let rawValue: Int
  
     static let floogled = Options(rawValue: 1 &lt;&lt; 0)
     static let jibjabbed = Options(rawValue: 1 &lt;&lt; 1)
  }
  </code></pre>
  
  <p>These are passed to some functions, for example <code>foo(options: .floogled)</code> and <code>bar(options: .jibjabbed)</code>.</p>
  
  <p>Now, usually when I call those functions, the intention is for all the options to be enabled. So I could define the functions with default values, for example</p>
  
  <pre><code>func foo(options: Options = [.floogled, .jibjabbed]) {
     ...
  }
  </code></pre>
  
  <p>and so on, and then just call <code>foo()</code>. So far so good.</p>
  
  <p>However, in the exceptional cases where I don't want to call those functions with all the options enabled, the usage would be much more intuitive if I could specify which options <em>not</em> to enable, rather than which options remain enabled. For example, I would rather like to call <code>foo(options: .notFloogled)</code> than <code>foo(options: .jibjabbed)</code>.</p>
  
  <p>I can think of two ways to do this. The first way is to change the definition of the option set so that its members are defined negatively; in other words</p>
  
  <pre><code>struct OptionsAlternative: OptionSet {
      let rawValue: Int
  
      static let notFloogled = Options(rawValue: 1 &lt;&lt; 0)
      static let notJibjabbed = Options(rawValue: 1 &lt;&lt; 1)
  }
  </code></pre>
  
  <p>The functions would then be defined with no options disabled by default; i.e.</p>
  
  <pre><code>func foo(options: OptionsAlternative = []) {
     ...
  }
  </code></pre>
  
  <p>And I could call it like <code>foo()</code> for the default behaviour, or <code>foo(options: .notFloogled)</code> when I need to disable specific options. However, I don't want to do this because it makes the implementation of the functions unintuitive. I would have to implement the parts that take the options into account in a double-negative fashion; compare how clumsy this is:</p>
  
  <pre><code>if !options.contains(.notFloogled) {
     // Floogling is enabled. Floogle the foo.
     ...
  }
  </code></pre>
  
  <p>as opposed to </p>
  
  <pre><code>if options.contains(.floogled) {
     // Floogling is enabled. Floogle the foo.
     ...
  }
  </code></pre>
  
  <p>The second way is to include members to indicate the presence of options, as in the original solution, <em>as well as</em> convenience members to indicate the absence of options. I.e.</p>
  
  <pre><code>extension Options {
     /// Not floogled; only jibjabbed.
     static let notFloogled: Options = [.jibjabbed]
  
     /// Not jibjabbed; only floogled.
     static let notJibjabbed: Options = [.floogled]
  }
  </code></pre>
  
  <p>However, this doesn't work if I want to disable multiple options (which was arguably a major reason to use an option set in the first place). For example, if I now call <code>foo(options: [.notFloogled, .notJibjabbed])</code>, I get an option set with <em>both</em> floogling and jibjabbing enabled, rather than <em>neither</em>.</p>
  
  <p>Is there another way of doing what I'm trying to achieve while keeping the implementation and usage as intuitive as possible?</p>