]> git.lizzy.rs Git - rust.git/commit
Implement Add on Option types
authorBen Striegel <ben.striegel@gmail.com>
Tue, 12 Mar 2013 02:46:16 +0000 (22:46 -0400)
committerBen Striegel <ben.striegel@gmail.com>
Tue, 12 Mar 2013 02:46:16 +0000 (22:46 -0400)
commita21b43c6bbb0edcf4dfe9913a084f28eb950b364
treec1a6875ae71cc13fb24aa4a3ac6a642a9e95c577
parenta6bb4a0f1a61ab00e09c4cb24dfff95c6c2481c7
Implement Add on Option types

This will allow you to use the + operator to add together any two
Options, assuming that the contents of each Option likewise implement
+. So Some(4) + Some(1) == Some(5), and adding with None leaves the
other value unchanged.

This might be monoidic? I don't know what that word means!
src/libcore/option.rs
src/test/run-pass/option_addition.rs [new file with mode: 0644]