<div dir="ltr">Hi,<br><br>Recently I needed to implement `contains` methods to check if a range contains another range. I think those are basic operations and suitable for the standard library.<br><br>Although it may seem easy to implement such `contains` methods whenever we need them, their precise specifications are too complicated to do so.<br><br>e.g.<br><br>let a: ClosedRange&lt;Int&gt; = 2...7<br>a.contains(3...5) // `true`<br>a.contains(3...7) // also `true`<br>a.contains(3..&lt;8) // still `true` because all values contained in `3..&lt;8` are also in `a`<br>a.contains(3..&lt;9) // `false`<br><br>let b: ClosedRange&lt;Float&gt; = 2...7<br>b.contains(3...5) // `true`<br>b.contains(3...7) // `true`<br>b.contains(3..&lt;8) // `false` because { x | 7.0 &lt; x &lt; 8.0 } is not contained in `a`<br><br>let c: Range&lt;Float&gt; = 2..&lt;7<br>c.contains(3...5) // `true`<br>c.contains(3..&lt;7) // `true`<br>c.contains(3...7) // `false` because 7.0 is not contained in `a`<br><br>My experimental implementation is here:<br><a href="https://github.com/koher/range-contains">https://github.com/koher/range-contains</a><br>(Currently does not support one-sided ranges)<br><br>What are your thoughts about them?<br><br>--<br>Yuta<br></div>