title: How can I test if a value lies within a Range?
body: <p>I'd like to be able to create a <a href="http://doc.rust-lang.org/std/ops/struct.Range.html" rel="noreferrer"><code>Range</code></a> and then test if a variable is contained in that range. Something that looks like this: </p>
  
  <pre><code>fn main() {
      let a = 3..5;
      assert!(a.contains(4));
  }
  </code></pre>
  
  <p>Right now, the only obvious thing I see is to use <a href="http://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.any" rel="noreferrer"><code>Iterator::any</code></a>. This is ugly because it would take an O(1) operation and make it O(n):</p>
  
  <pre><code>fn main() {
      let mut a = 3..5;
      assert!(a.any(|v: i32| v == 4));
  }
  </code></pre>