aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_vec.rs
diff options
context:
space:
mode:
authorTim Chevalier <[email protected]>2011-05-02 11:23:07 -0700
committerGraydon Hoare <[email protected]>2011-05-02 12:16:29 -0700
commitaa25f22f197682de3b18fc4c8ba068d1feda220f (patch)
tree6d01f8fbb5680964fd9c53564c96aa58cb75d3d1 /src/lib/_vec.rs
parentrustc: Add a "fat tydesc" LLVM type to trans (diff)
downloadrust-aa25f22f197682de3b18fc4c8ba068d1feda220f.tar.xz
rust-aa25f22f197682de3b18fc4c8ba068d1feda220f.zip
Use different syntax for checks that matter to typestate
This giant commit changes the syntax of Rust to use "assert" for "check" expressions that didn't mean anything to the typestate system, and continue using "check" for checks that are used as part of typestate checking. Most of the changes are just replacing "check" with "assert" in test cases and rustc.
Diffstat (limited to 'src/lib/_vec.rs')
-rw-r--r--src/lib/_vec.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs
index 126bf363..4761a867 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/_vec.rs
@@ -131,7 +131,7 @@ fn len_set[T](array[T] v, uint n) {
}
fn buf_off[T](array[T] v, uint offset) -> vbuf {
- check (offset < len[T](v));
+ assert (offset < len[T](v));
ret rustrt.vec_buf[T](v, offset);
}
@@ -149,9 +149,10 @@ fn last[T](array[T] v) -> option.t[T] {
}
// Returns elements from [start..end) from v.
+
fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
- check (start <= end);
- check (end <= len[T](v));
+ assert (start <= end);
+ assert (end <= len[T](v));
auto result = alloc[T](end - start);
let uint i = start;
while (i < end) {
@@ -163,7 +164,7 @@ fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
fn shift[T](&mutable array[T] v) -> T {
auto ln = len[T](v);
- check(ln > 0u);
+ assert (ln > 0u);
auto e = v.(0);
v = slice[T](v, 1u, ln);
ret e;
@@ -171,7 +172,7 @@ fn shift[T](&mutable array[T] v) -> T {
fn pop[T](&mutable array[T] v) -> T {
auto ln = len[T](v);
- check(ln > 0u);
+ assert (ln > 0u);
ln -= 1u;
auto e = v.(ln);
v = slice[T](v, 0u, ln);