]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agostd: Fully stabilize Option<T>
Alex Crichton [Sun, 14 Dec 2014 18:34:23 +0000 (10:34 -0800)]
std: Fully stabilize Option<T>

This commit takes a second pass through the `std::option` module to fully
stabilize any lingering methods inside of it.

These items were made stable as-is

* Some
* None
* as_mut
* expect
* unwrap
* unwrap_or
* unwrap_or_else
* map
* map_or
* map_or_else
* and_then
* or_else
* unwrap_or_default
* Default implementation
* FromIterator implementation
* Copy implementation

These items were made stable with modifications

* iter - now returns a struct called Iter
* iter_mut - now returns a struct called IterMut
* into_iter - now returns a struct called IntoIter, Clone is never implemented

This is a breaking change due to the modifications to the names of the iterator
types returned. Code referencing the old names should updated to referencing the
newer names instead. This is also a breaking change due to the fact that
`IntoIter` no longer implements the `Clone` trait.

These items were explicitly not stabilized

* as_slice - waiting on indexing conventions
* as_mut_slice - waiting on conventions with as_slice as well
* cloned - the API was still just recently added
* ok_or - API remains experimental
* ok_or_else - API remains experimental

[breaking-change]

9 years agoauto merge of #19467 : japaric/rust/uc, r=alexcrichton
bors [Sat, 13 Dec 2014 22:57:21 +0000 (22:57 +0000)]
auto merge of #19467 : japaric/rust/uc, r=alexcrichton

This PR moves almost all our current uses of closures, both in public API and internal uses, to the new "unboxed" closures system.

In most cases, downstream code that *only uses* closures will continue to work as it is. The reason is that the `|| {}` syntax can be inferred either as a boxed or an "unboxed" closure according to the context. For example the following code will continue to work:

``` rust
some_option.map(|x| x.transform_with(upvar))
```

And will get silently upgraded to an "unboxed" closure.

In some other cases, it may be necessary to "annotate" which `Fn*` trait the closure implements:

```
// Change this
|x| { /* body */}
// to either of these
|: x| { /* body */}  // closure implements the FnOnce trait
|&mut : x| { /* body */}  // FnMut
|&: x| { /* body */}  // Fn
```

This mainly occurs when the closure is assigned to a variable first, and then passed to a function/method.

``` rust
let closure = |: x| x.transform_with(upvar);
some.option.map(closure)
```

(It's very likely that in the future, an improved inference engine will make this annotation unnecessary)

Other cases that require annotation are closures that implement some trait via a blanket `impl`, for example:

- `std::finally::Finally`
- `regex::Replacer`
- `std::str::CharEq`

``` rust
string.trim_left_chars(|c: char| c.is_whitespace())
//~^ ERROR: the trait `Fn<(char,), bool>` is not implemented for the type `|char| -> bool`
string.trim_left_chars(|&: c: char| c.is_whitespace())  // OK
```

Finally, all implementations of traits that contain boxed closures in the arguments of their methods are now broken. And will need to be updated to use unboxed closures. These are the main affected traits:

- `serialize::Decoder`
- `serialize::DecoderHelpers`
- `serialize::Encoder`
- `serialize::EncoderHelpers`
- `rustrt::ToCStr`

For example, change this:

``` rust
// libserialize/json.rs
impl<'a> Encoder<io::IoError> for Encoder<'a> {
    fn emit_enum(&mut self,
                 _name: &str,
                 f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
        f(self)
    }
}
```

to:

``` rust
// libserialize/json.rs
impl<'a> Encoder<io::IoError> for Encoder<'a> {
    fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult
    {
        f(self)
    }
}
```

[breaking-change]

---

### How the `Fn*` bound has been selected

I've chosen the bounds to make the functions/structs as "generic as possible", i.e. to let them allow the maximum amount of input.

- An `F: FnOnce` bound accepts the three kinds of closures: `|:|`, `|&mut:|` and `|&:|`.
- An `F: FnMut` bound only accepts "non-consuming" closures: `|&mut:|` and `|&:|`.
- An `F: Fn` bound only accept the "immutable environment" closures: `|&:|`.

This means that whenever possible the `FnOnce` bound has been used, if the `FnOnce` bound couldn't be used, then the `FnMut` was used. The `Fn` bound was never used in the whole repository.

The `FnMut` bound was the most used, because it resembles the semantics of the current boxed closures: the closure can modify its environment, and the closure may be called several times.

The `FnOnce` bound allows new semantics: you can move out the upvars when the closure is called. This can be effectively paired with the `move || {}` syntax to transfer ownership from the environment to the closure caller.

In the case of trait methods, is hard to select the "right" bound since we can't control how the trait may be implemented by downstream users. In these cases, I have selected the bound based on how we use these traits in the repository. For this reason the selected bounds may not be ideal, and may require tweaking before stabilization.

r? @aturon

9 years agolibrustc_borrowck: add `#![feature(unboxed_closures)]`
Jorge Aparicio [Sat, 13 Dec 2014 22:40:34 +0000 (17:40 -0500)]
librustc_borrowck: add `#![feature(unboxed_closures)]`

9 years agolibstd: add missing imports
Jorge Aparicio [Sat, 13 Dec 2014 20:09:33 +0000 (15:09 -0500)]
libstd: add missing imports

9 years agoRemove some unnecessary `move` keywords
Jorge Aparicio [Sat, 13 Dec 2014 16:08:27 +0000 (11:08 -0500)]
Remove some unnecessary `move` keywords

9 years agolibtest: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 22:00:29 +0000 (17:00 -0500)]
libtest: use unboxed closures

9 years agolibrustc_driver: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 21:32:45 +0000 (16:32 -0500)]
librustc_driver: use unboxed closures

9 years agolibrustc_typeck: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 21:04:19 +0000 (16:04 -0500)]
librustc_typeck: use unboxed closures

9 years agolibrustdoc: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 20:22:19 +0000 (15:22 -0500)]
librustdoc: use unboxed closures

9 years agolibrustc_trans: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 18:44:51 +0000 (13:44 -0500)]
librustc_trans: use unboxed closures

9 years agolibrustc_trans: fix fallout
Jorge Aparicio [Tue, 9 Dec 2014 16:00:41 +0000 (11:00 -0500)]
librustc_trans: fix fallout

9 years agolibrustc_typeck: fix fallout
Jorge Aparicio [Tue, 9 Dec 2014 13:51:04 +0000 (08:51 -0500)]
librustc_typeck: fix fallout

9 years agolibrustc: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 01:26:43 +0000 (20:26 -0500)]
librustc: use unboxed closures

9 years agolibrustc_llvm: use unboxed closures
Jorge Aparicio [Tue, 9 Dec 2014 01:17:18 +0000 (20:17 -0500)]
librustc_llvm: use unboxed closures

9 years agolibrustc_trans: fix fallout
Jorge Aparicio [Tue, 9 Dec 2014 01:00:29 +0000 (20:00 -0500)]
librustc_trans: fix fallout

9 years agolibrustc_back: use unboxed closures
Jorge Aparicio [Mon, 8 Dec 2014 23:35:22 +0000 (18:35 -0500)]
librustc_back: use unboxed closures

9 years agolibrustc: fix fallout
Jorge Aparicio [Mon, 8 Dec 2014 19:14:06 +0000 (14:14 -0500)]
librustc: fix fallout

9 years agolibsyntax: use unboxed closures
Jorge Aparicio [Mon, 8 Dec 2014 18:28:32 +0000 (13:28 -0500)]
libsyntax: use unboxed closures

9 years agoFix benches
Jorge Aparicio [Mon, 8 Dec 2014 13:35:34 +0000 (08:35 -0500)]
Fix benches

9 years agolibstd: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 19:15:25 +0000 (14:15 -0500)]
libstd: use unboxed closures

9 years agolibrustrt: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 18:22:04 +0000 (13:22 -0500)]
librustrt: use unboxed closures

9 years agolibregex_macros: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 17:36:42 +0000 (12:36 -0500)]
libregex_macros: use unboxed closures

9 years agolibcollections: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 17:17:33 +0000 (12:17 -0500)]
libcollections: use unboxed closures

9 years agolibserialize: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 16:59:59 +0000 (11:59 -0500)]
libserialize: use unboxed closures

9 years agolibregex: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 16:14:43 +0000 (11:14 -0500)]
libregex: use unboxed closures

9 years agolibarena: use unboxed closures
Jorge Aparicio [Sun, 7 Dec 2014 16:11:15 +0000 (11:11 -0500)]
libarena: use unboxed closures

9 years agolibregex: fix fallout in doc tests
Jorge Aparicio [Mon, 8 Dec 2014 01:32:53 +0000 (20:32 -0500)]
libregex: fix fallout in doc tests

9 years agolibregex: impl Replacer for FnMut(&Captures) -> String implementors
Jorge Aparicio [Sun, 7 Dec 2014 00:35:02 +0000 (19:35 -0500)]
libregex: impl Replacer for FnMut(&Captures) -> String implementors

9 years agolibrustc: fix fallout
Jorge Aparicio [Sat, 6 Dec 2014 22:55:55 +0000 (17:55 -0500)]
librustc: fix fallout

9 years agolibrbml: use unboxed closures in free functions
Jorge Aparicio [Sat, 6 Dec 2014 22:44:01 +0000 (17:44 -0500)]
librbml: use unboxed closures in free functions

9 years agolibrbml: fix fallout
Jorge Aparicio [Sat, 6 Dec 2014 21:53:18 +0000 (16:53 -0500)]
librbml: fix fallout

9 years agolibserialize: use unboxed closures
Jorge Aparicio [Sat, 6 Dec 2014 19:30:22 +0000 (14:30 -0500)]
libserialize: use unboxed closures

9 years agolibrand: use unboxed closures in `distributions` module
Jorge Aparicio [Sat, 6 Dec 2014 17:30:35 +0000 (12:30 -0500)]
librand: use unboxed closures in `distributions` module

9 years agolibgraphviz: use unboxed closures in `LabelText` methods
Jorge Aparicio [Sat, 6 Dec 2014 17:28:18 +0000 (12:28 -0500)]
libgraphviz: use unboxed closures in `LabelText` methods

9 years agolibgetopts: use unboxed closures in `each_split_within`
Jorge Aparicio [Sat, 6 Dec 2014 17:26:58 +0000 (12:26 -0500)]
libgetopts: use unboxed closures in `each_split_within`

9 years agolibcore: use unboxed closures in `slice::raw` free functions
Jorge Aparicio [Sat, 6 Dec 2014 17:11:15 +0000 (12:11 -0500)]
libcore: use unboxed closures in `slice::raw` free functions

9 years agolibcore: use unboxed closures in `float_to_str_bytes_common`
Jorge Aparicio [Sat, 6 Dec 2014 17:05:38 +0000 (12:05 -0500)]
libcore: use unboxed closures in `float_to_str_bytes_common`

9 years agolibcollections: use unboxed closures in `VecMap` methods
Jorge Aparicio [Fri, 5 Dec 2014 22:03:04 +0000 (17:03 -0500)]
libcollections: use unboxed closures in `VecMap` methods

9 years agolibgraphviz: fix fallout
Jorge Aparicio [Fri, 5 Dec 2014 23:17:24 +0000 (18:17 -0500)]
libgraphviz: fix fallout

9 years agolibcollections: use unboxed closures in `[Clone]SliceAllocPrelude` methods
Jorge Aparicio [Fri, 5 Dec 2014 21:59:13 +0000 (16:59 -0500)]
libcollections: use unboxed closures in `[Clone]SliceAllocPrelude` methods

9 years agolibcollections: use unboxed closures in `DList` methods
Jorge Aparicio [Fri, 5 Dec 2014 21:55:16 +0000 (16:55 -0500)]
libcollections: use unboxed closures in `DList` methods

9 years agolibcollections: use unboxed closures in `Vec` methods
Jorge Aparicio [Fri, 5 Dec 2014 21:54:09 +0000 (16:54 -0500)]
libcollections: use unboxed closures in `Vec` methods

9 years agolibcollections: use unboxed closures in `Bitv` methods
Jorge Aparicio [Fri, 5 Dec 2014 21:44:03 +0000 (16:44 -0500)]
libcollections: use unboxed closures in `Bitv` methods

9 years agolibcollections: use unboxed closures in `TreeMap` methods
Jorge Aparicio [Fri, 5 Dec 2014 21:16:07 +0000 (16:16 -0500)]
libcollections: use unboxed closures in `TreeMap` methods

9 years agolibcore: use unboxed closures in the `char` module
Jorge Aparicio [Fri, 5 Dec 2014 18:53:25 +0000 (13:53 -0500)]
libcore: use unboxed closures in the `char` module

9 years agolibcore: use unboxed closures in `Formatter` methods
Jorge Aparicio [Fri, 5 Dec 2014 18:06:24 +0000 (13:06 -0500)]
libcore: use unboxed closures in `Formatter` methods

9 years agolibcore: fix fallout in doc tests
Jorge Aparicio [Fri, 5 Dec 2014 16:55:36 +0000 (11:55 -0500)]
libcore: fix fallout in doc tests

9 years agolibrustrt: fix fallout
Jorge Aparicio [Fri, 5 Dec 2014 15:52:51 +0000 (10:52 -0500)]
librustrt: fix fallout

9 years agolibcoretest: fix fallout
Jorge Aparicio [Fri, 5 Dec 2014 15:49:51 +0000 (10:49 -0500)]
libcoretest: fix fallout

9 years agoFix run pass test
Jorge Aparicio [Fri, 5 Dec 2014 15:16:53 +0000 (10:16 -0500)]
Fix run pass test

9 years agolibstd: fix fallout
Jorge Aparicio [Fri, 5 Dec 2014 13:54:28 +0000 (08:54 -0500)]
libstd: fix fallout

9 years agolibcore: use unboxed closures in the `finally` module
Jorge Aparicio [Fri, 5 Dec 2014 13:24:40 +0000 (08:24 -0500)]
libcore: use unboxed closures in the `finally` module

9 years agolibcore: use unboxed closures in `SlicePrelude` methods
Jorge Aparicio [Fri, 5 Dec 2014 07:04:33 +0000 (02:04 -0500)]
libcore: use unboxed closures in `SlicePrelude` methods

9 years agolibcore: use unboxed closures in the fields of `MutSplits`
Jorge Aparicio [Fri, 5 Dec 2014 06:00:50 +0000 (01:00 -0500)]
libcore: use unboxed closures in the fields of `MutSplits`

9 years agolibstd: fix fallout
Jorge Aparicio [Fri, 5 Dec 2014 04:50:57 +0000 (23:50 -0500)]
libstd: fix fallout

9 years agolibcore: use unboxed closures in the fields of `Splits`
Jorge Aparicio [Fri, 5 Dec 2014 04:47:40 +0000 (23:47 -0500)]
libcore: use unboxed closures in the fields of `Splits`

9 years agolibcore: fix fallout in doctests
Jorge Aparicio [Fri, 5 Dec 2014 02:31:49 +0000 (21:31 -0500)]
libcore: fix fallout in doctests

9 years agolibcoretest: fix fallout in unit tests
Jorge Aparicio [Fri, 5 Dec 2014 01:01:55 +0000 (20:01 -0500)]
libcoretest: fix fallout in unit tests

9 years agolibcollections: fix fallout in unit tests
Jorge Aparicio [Fri, 5 Dec 2014 00:03:07 +0000 (19:03 -0500)]
libcollections: fix fallout in unit tests

9 years agolibrustdoc: fix fallout
Jorge Aparicio [Thu, 4 Dec 2014 22:58:50 +0000 (17:58 -0500)]
librustdoc: fix fallout

9 years agolibstd: fix fallout
Jorge Aparicio [Thu, 4 Dec 2014 22:29:41 +0000 (17:29 -0500)]
libstd: fix fallout

9 years agolibunicode: fix fallout
Jorge Aparicio [Thu, 4 Dec 2014 22:25:18 +0000 (17:25 -0500)]
libunicode: fix fallout

9 years agolibcore: impl CharEq for FnMut(char) -> bool implementors
Jorge Aparicio [Thu, 4 Dec 2014 21:17:07 +0000 (16:17 -0500)]
libcore: impl CharEq for FnMut(char) -> bool implementors

9 years agolibcore: use unboxed closures in `ExactSizeIterator` methods
Jorge Aparicio [Thu, 4 Dec 2014 21:13:12 +0000 (16:13 -0500)]
libcore: use unboxed closures in `ExactSizeIterator` methods

9 years agolibcollections: fix unit tests
Jorge Aparicio [Thu, 4 Dec 2014 02:05:25 +0000 (21:05 -0500)]
libcollections: fix unit tests

9 years agoFix run-pass tests
Jorge Aparicio [Thu, 4 Dec 2014 01:42:22 +0000 (20:42 -0500)]
Fix run-pass tests

9 years agolibrustc: fix fallout
Jorge Aparicio [Thu, 4 Dec 2014 00:52:54 +0000 (19:52 -0500)]
librustc: fix fallout

9 years agolibregex: fix fallout
Jorge Aparicio [Thu, 4 Dec 2014 00:46:51 +0000 (19:46 -0500)]
libregex: fix fallout

9 years agolibcore: use unboxed closures in `IteratorExt` methods
Jorge Aparicio [Thu, 4 Dec 2014 00:43:25 +0000 (19:43 -0500)]
libcore: use unboxed closures in `IteratorExt` methods

9 years agolibcore: use unboxed closures in the fields of `Unfold`
Jorge Aparicio [Wed, 3 Dec 2014 20:51:47 +0000 (15:51 -0500)]
libcore: use unboxed closures in the fields of `Unfold`

9 years agolibcoretest: fix fallout
Jorge Aparicio [Wed, 3 Dec 2014 15:09:53 +0000 (10:09 -0500)]
libcoretest: fix fallout

9 years agolibcore: use unboxed closures in the fields of `Inspect`
Jorge Aparicio [Wed, 3 Dec 2014 09:04:27 +0000 (04:04 -0500)]
libcore: use unboxed closures in the fields of `Inspect`

9 years agolibcore: use unboxed closures in the fields of `FlatMap`
Jorge Aparicio [Wed, 3 Dec 2014 08:07:16 +0000 (03:07 -0500)]
libcore: use unboxed closures in the fields of `FlatMap`

9 years agolibcore: use unboxed closures in the fields of `Scan`
Jorge Aparicio [Wed, 3 Dec 2014 06:59:31 +0000 (01:59 -0500)]
libcore: use unboxed closures in the fields of `Scan`

9 years agolibcore: use unboxed closures in the fields of `TakeWhile`
Jorge Aparicio [Wed, 3 Dec 2014 05:42:28 +0000 (00:42 -0500)]
libcore: use unboxed closures in the fields of `TakeWhile`

9 years agolibcore: use unboxed closures in the fields of `SkipWhile`
Jorge Aparicio [Wed, 3 Dec 2014 04:28:32 +0000 (23:28 -0500)]
libcore: use unboxed closures in the fields of `SkipWhile`

9 years agolibrustdoc: fix fallout
Jorge Aparicio [Wed, 3 Dec 2014 03:29:24 +0000 (22:29 -0500)]
librustdoc: fix fallout

9 years agolibstd: fix fallout
Jorge Aparicio [Wed, 3 Dec 2014 02:19:24 +0000 (21:19 -0500)]
libstd: fix fallout

9 years agolibcollections: fix fallout
Jorge Aparicio [Wed, 3 Dec 2014 02:05:30 +0000 (21:05 -0500)]
libcollections: fix fallout

9 years agolibcore: use unboxed closures in the fields of `FilterMap`
Jorge Aparicio [Wed, 3 Dec 2014 02:00:07 +0000 (21:00 -0500)]
libcore: use unboxed closures in the fields of `FilterMap`

9 years agolibrustc_trans: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 23:03:12 +0000 (18:03 -0500)]
librustc_trans: fix fallout

9 years agolibunicode: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 22:53:02 +0000 (17:53 -0500)]
libunicode: fix fallout

9 years agolibcore: use unboxed closures in the fields of `Filter`
Jorge Aparicio [Tue, 2 Dec 2014 22:49:42 +0000 (17:49 -0500)]
libcore: use unboxed closures in the fields of `Filter`

9 years agolibrustc_trans: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 20:17:55 +0000 (15:17 -0500)]
librustc_trans: fix fallout

9 years agolibrustc: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 19:56:00 +0000 (14:56 -0500)]
librustc: fix fallout

9 years agolibsyntax: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 19:46:01 +0000 (14:46 -0500)]
libsyntax: fix fallout

9 years agolibstd: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 19:28:35 +0000 (14:28 -0500)]
libstd: fix fallout

9 years agolibrustrt: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 19:24:40 +0000 (14:24 -0500)]
librustrt: fix fallout

9 years agolibcollections: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 19:07:40 +0000 (14:07 -0500)]
libcollections: fix fallout

9 years agolibcore: use unboxed closures in the fields of `Map`
Jorge Aparicio [Tue, 2 Dec 2014 18:59:08 +0000 (13:59 -0500)]
libcore: use unboxed closures in the fields of `Map`

9 years agolibcore: use unboxed closures in `Result` methods
Jorge Aparicio [Tue, 2 Dec 2014 17:47:07 +0000 (12:47 -0500)]
libcore: use unboxed closures in `Result` methods

9 years agoFix compile fail tests
Jorge Aparicio [Tue, 2 Dec 2014 17:42:39 +0000 (12:42 -0500)]
Fix compile fail tests

9 years agolibrustc_trans: fix fallout
Jorge Aparicio [Tue, 2 Dec 2014 03:52:22 +0000 (22:52 -0500)]
librustc_trans: fix fallout

9 years agolibcore: use unboxed closures in `Option` methods
Jorge Aparicio [Wed, 19 Nov 2014 23:06:41 +0000 (18:06 -0500)]
libcore: use unboxed closures in `Option` methods

9 years agoauto merge of #19582 : nikomatsakis/rust/crateification, r=alexcrichton
bors [Sat, 13 Dec 2014 20:02:15 +0000 (20:02 +0000)]
auto merge of #19582 : nikomatsakis/rust/crateification, r=alexcrichton

r? @alexcrichton

9 years agoauto merge of #19627 : steveklabnik/rust/testing_guide, r=cmr
bors [Sat, 13 Dec 2014 17:27:15 +0000 (17:27 +0000)]
auto merge of #19627 : steveklabnik/rust/testing_guide, r=cmr

9 years agoRevamped testing guide
Steve Klabnik [Sun, 7 Dec 2014 21:44:01 +0000 (16:44 -0500)]
Revamped testing guide

9 years agoauto merge of #19695 : arthurtw/rust/master, r=steveklabnik
bors [Sat, 13 Dec 2014 15:22:16 +0000 (15:22 +0000)]
auto merge of #19695 : arthurtw/rust/master, r=steveklabnik

9 years agoauto merge of #19685 : jbranchaud/rust/add-btreemap-iter-doctests, r=Gankro
bors [Sat, 13 Dec 2014 11:02:17 +0000 (11:02 +0000)]
auto merge of #19685 : jbranchaud/rust/add-btreemap-iter-doctests, r=Gankro

9 years agoSeparate borrowck into its own crate and remove dead code as well.
Niko Matsakis [Fri, 5 Dec 2014 19:17:35 +0000 (14:17 -0500)]
Separate borrowck into its own crate and remove dead code as well.