Reduce and clarify abuse of 'pure' in interner
This commit is contained in:
parent
0125532106
commit
3b5b29c7ec
3 changed files with 12 additions and 11 deletions
|
|
@ -28,7 +28,13 @@ fn intern<@T>(itr: interner<T>, val: T) -> uint {
|
|||
}
|
||||
}
|
||||
|
||||
pure fn get<@T>(itr: interner<T>, idx: uint) -> T { ret itr.vect[idx]; }
|
||||
|
||||
pure fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }
|
||||
// |get| isn't "pure" in the traditional sense, because it can go from
|
||||
// failing to returning a value as items are interned. But for typestate,
|
||||
// where we first check a pred and then rely on it, ceasing to fail is ok.
|
||||
pure fn get<@T>(itr: interner<T>, idx: uint) -> T {
|
||||
unchecked {
|
||||
itr.vect[idx]
|
||||
}
|
||||
}
|
||||
|
||||
fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue