diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-02-10 06:01:32 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-02-10 20:48:28 -0800 |
| commit | fdddf8f9e1d6738d42989a6d8a735dd58127e199 (patch) | |
| tree | 9e324f85345957929daed40aedeaf52d0199b33d /src/libcore/uint.rs | |
| parent | dbcb54f4dc44957c9505958655a16e678ee4396b (diff) | |
| download | rust-fdddf8f9e1d6738d42989a6d8a735dd58127e199.tar.gz rust-fdddf8f9e1d6738d42989a6d8a735dd58127e199.zip | |
put serializer into the build and encode full item paths
Diffstat (limited to 'src/libcore/uint.rs')
| -rw-r--r-- | src/libcore/uint.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libcore/uint.rs b/src/libcore/uint.rs index 2112399ba80..5799211865f 100644 --- a/src/libcore/uint.rs +++ b/src/libcore/uint.rs @@ -20,6 +20,20 @@ This is 2^wordsize - 1 */ const max_value: uint = 0u - 1u; +/* +Function: max +*/ +fn max(x: uint, y: uint) -> uint { + if x > y { x } else { y } +} + +/* +Function: min +*/ +fn min(x: uint, y: uint) -> uint { + if x < y { x } else { y } +} + /* Function: add */ pure fn add(x: uint, y: uint) -> uint { ret x + y; } @@ -252,6 +266,15 @@ Convert to a string */ fn str(i: uint) -> str { ret to_str(i, 10u); } +/* +Function: compl + +Computes the bitwise complement. +*/ +fn compl(i: uint) -> uint { + uint::max_value ^ i +} + #[cfg(test)] mod tests { |
