We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 161a82e commit 5792244Copy full SHA for 5792244
src/libcore/option.rs
@@ -8,6 +8,8 @@
8
* type.
9
*/
10
11
+use cmp::Eq;
12
+
13
/// The option type
14
enum Option<T> {
15
None,
@@ -247,6 +249,25 @@ impl<T: copy> Option<T> {
247
249
pure fn while_some(blk: fn(+T) -> Option<T>) { while_some(self, blk) }
248
250
}
251
252
+impl<T: Eq> Option<T> : Eq {
253
+ pure fn eq(&&other: Option<T>) -> bool {
254
+ match self {
255
+ None => {
256
+ match other {
257
+ None => true,
258
+ Some(_) => false
259
+ }
260
261
+ Some(self_contents) => {
262
263
+ None => false,
264
+ Some(other_contents) => self_contents.eq(other_contents)
265
266
267
268
269
+}
270
271
#[test]
272
fn test_unwrap_ptr() {
273
let x = ~0;
0 commit comments