diff options
| author | Roy Frostig <[email protected]> | 2010-08-03 17:52:35 -0700 |
|---|---|---|
| committer | Roy Frostig <[email protected]> | 2010-08-03 17:52:35 -0700 |
| commit | 085790a73a0527a06055ab0823066bc407a52741 (patch) | |
| tree | 87a68308532ff48ba73bcfb990b82dcc9213746a /src/lib/util.rs | |
| parent | Avoid mem cmp mem in trans even though it's an X86ism becase we don't always ... (diff) | |
| download | rust-085790a73a0527a06055ab0823066bc407a52741.tar.xz rust-085790a73a0527a06055ab0823066bc407a52741.zip | |
More stdlib hashmap bits (plus some drive-by extras).
Diffstat (limited to 'src/lib/util.rs')
| -rw-r--r-- | src/lib/util.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/util.rs b/src/lib/util.rs index 51f0707c..5d0f4b49 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -17,4 +17,11 @@ fn id[T](T x) -> T { ret x; } -type rational = rec(int num, int den); +/* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment + * the constraint once fixed. */ +type rational = rec(int num, int den); // : _int.positive(*.den); + +fn rational_leq(&rational x, &rational y) -> bool { + // NB: Uses the fact that rationals have positive denominators WLOG. + ret x.num * y.den <= y.num * x.den; +} |