about summary refs log tree commit diff
path: root/src/libserialize
AgeCommit message (Collapse)AuthorLines
2014-02-24auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichtonbors-3/+1
Commits for details. Highlights: - `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]` - a lot of `transmute`s removed outright or replaced with `as` (etc.)
2014-02-24Move extra::json to libserializeAlex Crichton-2/+2571
This also inverts the dependency between libserialize and libcollections. cc #8784
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-8/+10
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-24arena,std,serialize: remove some unnecessary transmutes.Huon Wilson-3/+1
`as`-able transmutes, duplication and manual slice decomposition are silly.
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-121/+0
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-22auto merge of #11863 : erickt/rust/hash, r=acrichtobors-0/+1
This PR merges `IterBytes` and `Hash` into a trait that allows for generic non-stream-based hashing. It makes use of @eddyb's default type parameter support in order to have a similar usage to the old `Hash` framework. Fixes #8038. Todo: - [x] Better documentation - [ ] Benchmark - [ ] Parameterize `HashMap` on a `Hasher`.
2014-02-22Warn about unnecessary parentheses upon assignmentEduard Bopp-1/+1
Closes #12366. Parentheses around assignment statements such as let mut a = (0); a = (1); a += (2); are not necessary and therefore an unnecessary_parens warning is raised when statements like this occur. The warning mechanism was refactored along the way to allow for code reuse between the routines for checking expressions and statements. Code had to be adopted throughout the compiler and standard libraries to comply with this modification of the lint.
2014-02-21std: rewrite Hash to make it more genericErick Tryzelaar-0/+1
This patch merges IterBytes and Hash traits, which clears up the confusion of using `#[deriving(IterBytes)]` to support hashing. Instead, it now is much easier to use the new `#[deriving(Hash)]` for making a type hashable with a stream hash. Furthermore, it supports custom non-stream-based hashers, such as if a value's hash was cached in a database. This does not yet replace the old IterBytes-hash with this new version.
2014-02-21libstd: Implement some convenience methods on vectorsPatrick Walton-0/+21
2014-02-20Mass rename if_ok! to try!Alex Crichton-6/+6
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20move extra::test to libtestLiigo Zhuang-5/+8
2014-02-14extern mod => extern crateAlex Crichton-5/+5
This was previously implemented, and it just needed a snapshot to go through
2014-02-13remove duplicate function from std::ptr (is_null, is_not_null, offset, ↵JeremyLetang-2/+1
mut_offset)
2014-02-13Move base64 and hex from libextra to libserializeLiigo Zhuang-0/+581
2014-02-09std: Move byteswap functions to memBrian Anderson-1/+1
2014-02-05pull extra::{serialize, ebml} into a separate libserialize crateJeff Olson-0/+1914
- `extra::json` didn't make the cut, because of `extra::json` required dep on `extra::TreeMap`. If/when `extra::TreeMap` moves out of `extra`, then `extra::json` could move into `serialize` - `libextra`, `libsyntax` and `librustc` depend on the newly created `libserialize` - The extensions to various `extra` types like `DList`, `RingBuf`, `TreeMap` and `TreeSet` for `Encodable`/`Decodable` were moved into the respective modules in `extra` - There is some trickery, evident in `src/libextra/lib.rs` where a stub of `extra::serialize` is set up (in `src/libextra/serialize.rs`) for use in the stage0 build, where the snapshot rustc is still making deriving for `Encodable` and `Decodable` point at extra. Big props to @huonw for help working out the re-export solution for this extra: inline extra::serialize stub fix stuff clobbered in rebase + don't reexport serialize::serialize no more globs in libserialize syntax: fix import of libserialize traits librustc: fix bad imports in encoder/decoder add serialize dep to librustdoc fix failing run-pass tests w/ serialize dep adjust uuid dep more rebase de-clobbering for libserialize fixing tests, pushing libextra dep into cfg(test) fix doc code in extra::json adjust index.md links to serialize and uuid library