about summary refs log tree commit diff
path: root/src/libextra/json.rs
AgeCommit message (Collapse)AuthorLines
2014-02-24Move extra::json to libserializeAlex Crichton-2294/+0
This also inverts the dependency between libserialize and libcollections. cc #8784
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-9/+7
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-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-1/+1
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-20Mass rename if_ok! to try!Alex Crichton-52/+52
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-18auto merge of #12361 : sfackler/rust/rustdoc-test-extern, r=alexcrichtonbors-0/+5
2014-02-18rustdoc: Only inject extern crates if not presentSteven Fackler-0/+5
2014-02-18Spellcheck library docs.Huon Wilson-5/+5
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-1/+1
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-14Fix all code examplesAlex Crichton-1/+1
2014-02-14extern mod => extern crateAlex Crichton-6/+6
This was previously implemented, and it just needed a snapshot to go through
2014-02-08extra::json: remove the use of `unsafe` char transmutes.Huon Wilson-139/+139
Avoid using -1 as a char sentinel, when Option<char> is the perfect thing.
2014-02-07moved collections from libextra into libcollectionsHeroesGrave-4/+8
2014-02-05pull extra::{serialize, ebml} into a separate libserialize crateJeff Olson-9/+13
- `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
2014-02-03extra: Remove io_error usageAlex Crichton-59/+86
2014-01-30Remove Times traitBrendan Zabarauskas-1/+1
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-29Removing do keyword from libextraScott Lawrence-2/+2
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-5/+5
from_utf8_owned() behavior
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-11/+11
2014-01-21Remove unnecessary parentheses.Huon Wilson-2/+2
2014-01-19auto merge of #11649 : FlaPer87/rust/pow, r=cmrbors-1/+1
There was an old and barely used implementation of pow, which expected both parameters to be uint and required more traits to be implemented. Since a new implementation for `pow` landed, I'm proposing to remove this old impl in favor of the new one. The benchmark shows that the new implementation is faster than the one being removed: ``` test num::bench::bench_pow_function ..bench: 9429 ns/iter (+/- 2055) test num::bench::bench_pow_with_uint_function ...bench: 28476 ns/iter (+/- 2202) ```
2014-01-19extra::json: add documentation and examplesmusitdev-1/+1
2014-01-19extra::json: add documentation and examplesmusitdev-1/+1
2014-01-19Squashed commit of the following:musitdev-1/+222
commit d00623d60afd460755b749ad5f94935f756f29d2 Author: musitdev <philippe.delrieu@free.fr> Date: Sat Jan 4 22:31:40 2014 +0100 correct last comments. commit ef09d6b6d1eebbd7c713c9dad96ed7bfc19dd884 Author: musitdev <philippe.delrieu@free.fr> Date: Thu Jan 2 20:28:53 2014 +0100 update with the last remarks. commit 46a028fe1fcdc2a7dcdd78a63001793eff614349 Author: musitdev <philippe.delrieu@free.fr> Date: Thu Jan 2 10:17:18 2014 +0100 wrap example code in main function. commit 2472901929bef09786b7aef8ca7c89fbe67d8e3e Author: musitdev <philippe.delrieu@free.fr> Date: Mon Dec 30 19:32:46 2013 +0100 Correct code to compile. commit ed96b2223176781743e984af0e19abcb82150f1f Author: musitdev <philippe.delrieu@free.fr> Date: Thu Dec 5 11:32:28 2013 +0100 Correct the comment based on the PR comment. Change init call to new to reflect last change. commit 38b0390c3533a16f822a6df5f90b907bd8ed6edc Author: musitdev <philippe.delrieu@free.fr> Date: Wed Dec 4 22:34:25 2013 +0100 correct from_utf8_owned call. commit 08bed4c5f4fadf93ec457b605a1a1354323d2f5c Author: musitdev <philippe.delrieu@free.fr> Date: Wed Dec 4 22:12:41 2013 +0100 correct code ''' commit 02fddcbe2ab37fe842872691105bc4c5cff5abb5 Author: musitdev <philippe.delrieu@free.fr> Date: Wed Dec 4 13:25:54 2013 +0100 correct typing error commit b26830b8ddb49f551699e791832ed20640a0fafc Author: musitdev <philippe.delrieu@free.fr> Date: Wed Dec 4 13:18:39 2013 +0100 pass make check commit e87c4f53286122efd0d2364ea45600d4fa4d5744 Author: musitdev <philippe.delrieu@free.fr> Date: Wed Dec 4 10:47:24 2013 +0100 Add Json example and documentation.
2014-01-18Replace old pow_with_uint with the new pow funcFlavio Percoco-1/+1
There was an old and barely used implementation of pow, which expected both parameters to be uint and required more traits to be implemented. Since a new implementation for `pow` landed, I'm proposing to remove this old impl in favor of the new one. The benchmark shows that the new implementation is faster than the one being removed: test num::bench::bench_pow_function ..bench: 9429 ns/iter (+/- 2055) test num::bench::bench_pow_with_uint_function ...bench: 28476 ns/iter (+/- 2202)
2014-01-17Tweak the interface of std::ioAlex Crichton-2/+2
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-08Remove the io::Decorator traitAlex Crichton-5/+3
This is just an unnecessary trait that no one's ever going to parameterize over and it's more useful to just define the methods directly on the types themselves. The implementors of this type almost always don't want inner_mut_ref() but they're forced to define it as well.
2014-01-07extratest: Fix all leaked trait importsAlex Crichton-2/+1
2013-12-11Make 'self lifetime illegal.Erik Price-44/+44
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-04Rename extra::json::*::init() constructors to *::new()Kevin Ballard-48/+48
2013-11-29extra: missed a couple `@` in jsonErick Tryzelaar-9/+9
2013-11-29extra: json::Encoder should take a &mut io::WriterErick Tryzelaar-50/+50
2013-11-29extra: Rename json constructors into *::initErick Tryzelaar-69/+77
2013-11-29Remove some unnecessary impls from jsonErick Tryzelaar-8/+0
2013-11-29Remove @ from json::ErrorErick Tryzelaar-41/+41
2013-11-28Register new snapshotsAlex Crichton-5/+5
2013-11-26librustc: Fix merge fallout.Patrick Walton-2/+2
2013-11-26test: Remove all remaining non-procedure uses of `do`.Patrick Walton-16/+16
2013-11-26librustuv: Remove all non-`proc` uses of `do` from `libextra` andPatrick Walton-3/+1
`librustuv`.
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-5/+5
2013-11-24extra: improve the errors for the JSON Decoder.Huon Wilson-25/+126
Fixes #4244.
2013-11-19libextra: Convert uses of `&fn(A)->B` to `|A|->B`.Patrick Walton-61/+54
2013-11-11Move std::rt::io to std::ioAlex Crichton-6/+6
2013-10-28Remove the extension traits for Readers/WritersAlex Crichton-2/+1
These methods are all excellent candidates for default methods, so there's no need to require extra imports of various traits.
2013-10-24Remove even more of std::ioAlex Crichton-96/+96
Big fish fried here: extra::json most of the compiler extra::io_util removed extra::fileinput removed Fish left to fry extra::ebml
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-5/+0
2013-10-23Making fields in std and extra : private #4386reedlepee-3/+8
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-33/+33
Who doesn't like a massive renaming?
2013-10-01remove the `float` typeDaniel Micay-110/+101
It is simply defined as `f64` across every platform right now. A use case hasn't been presented for a `float` type defined as the highest precision floating point type implemented in hardware on the platform. Performance-wise, using the smallest precision correct for the use case greatly saves on cache space and allows for fitting more numbers into SSE/AVX registers. If there was a use case, this could be implemented as simply a type alias or a struct thanks to `#[cfg(...)]`. Closes #6592 The mailing list thread, for reference: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-09-30extra: Remove usage of fmt!Alex Crichton-34/+34
2013-09-16extra::json: use a different encoding for enums.Corey Richardson-15/+24
It now uses `{"type": VariantName, "fields": [...]}`, which, according to @Seldaek, since all enums will have the same "shape" rather than being a weird ad-hoc array, will optimize better in javascript JITs. It also looks prettier, and makes more sense.