diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-07-12 01:38:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-07-14 09:29:12 -0700 |
| commit | e3211fa1f1f24268b91b0c89cb312e70499d41f3 (patch) | |
| tree | adcfe3900f33641ac4c73bff3e61f048d7270157 /src/libextra | |
| parent | 242606c79339e2d2e3cf15cc8f02bd6ebc0b8c44 (diff) | |
| download | rust-e3211fa1f1f24268b91b0c89cb312e70499d41f3.tar.gz rust-e3211fa1f1f24268b91b0c89cb312e70499d41f3.zip | |
Purge the last remnants of the old TLS api
Closes #3273
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/rl.rs | 26 | ||||
| -rw-r--r-- | src/libextra/sort.rs | 35 |
2 files changed, 15 insertions, 46 deletions
diff --git a/src/libextra/rl.rs b/src/libextra/rl.rs index c1eeb5005b2..b7b74694475 100644 --- a/src/libextra/rl.rs +++ b/src/libextra/rl.rs @@ -66,24 +66,28 @@ pub unsafe fn read(prompt: &str) -> Option<~str> { } } -pub type CompletionCb<'self> = @fn(~str, &'self fn(~str)); +pub type CompletionCb = @fn(~str, @fn(~str)); -fn complete_key(_v: @CompletionCb) {} +#[cfg(not(stage0))] +static complete_key: local_data::Key<@CompletionCb> = &[]; +#[cfg(stage0)] +fn complete_key(_: @CompletionCb) {} /// Bind to the main completion callback pub unsafe fn complete(cb: CompletionCb) { - local_data::set(complete_key, @(cb)); + local_data::set(complete_key, @cb); extern fn callback(line: *c_char, completions: *()) { - unsafe { - let cb = *local_data::get(complete_key, |k| k.map(|&k| *k)) - .get(); - - do cb(str::raw::from_c_str(line)) |suggestion| { - do str::as_c_str(suggestion) |buf| { - rustrt::linenoiseAddCompletion(completions, buf); + do local_data::get(complete_key) |cb| { + let cb = **cb.unwrap(); + + unsafe { + do cb(str::raw::from_c_str(line)) |suggestion| { + do str::as_c_str(suggestion) |buf| { + rustrt::linenoiseAddCompletion(completions, buf); + } } - } +} } } diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index d4d6162a919..db4ad43e41d 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -1195,39 +1195,4 @@ mod big_tests { isSorted(arr); } } - - struct LVal<'self> { - val: uint, - key: &'self fn:Copy(@uint), - } - - #[unsafe_destructor] - impl<'self> Drop for LVal<'self> { - fn drop(&self) { - let x = unsafe { local_data::get(self.key, |k| k.map(|&k| *k)) }; - match x { - Some(@y) => { - unsafe { - local_data::set(self.key, @(y+1)); - } - } - _ => fail!("Expected key to work"), - } - } - } - - impl<'self> Ord for LVal<'self> { - fn lt<'a>(&self, other: &'a LVal<'self>) -> bool { - (*self).val < other.val - } - fn le<'a>(&self, other: &'a LVal<'self>) -> bool { - (*self).val <= other.val - } - fn gt<'a>(&self, other: &'a LVal<'self>) -> bool { - (*self).val > other.val - } - fn ge<'a>(&self, other: &'a LVal<'self>) -> bool { - (*self).val >= other.val - } - } } |
