about summary refs log tree commit diff
path: root/src/libstd/fmt
AgeCommit message (Collapse)AuthorLines
2014-02-15auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfacklerbors-6/+6
It's too easy to forget the `rust` tag to test something. Closes #11698
2014-02-15impl fmt::Pointer for &T and &mut TCorey Richardson-1/+11
2014-02-14Fix all code examplesAlex Crichton-6/+6
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-5/+5
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-77/+77
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-06Remove std::conditionAlex Crichton-41/+24
This has been a long time coming. Conditions in rust were initially envisioned as being a good alternative to error code return pattern. The idea is that all errors are fatal-by-default, and you can opt-in to handling the error by registering an error handler. While sounding nice, conditions ended up having some unforseen shortcomings: * Actually handling an error has some very awkward syntax: let mut result = None; let mut answer = None; io::io_error::cond.trap(|e| { result = Some(e) }).inside(|| { answer = Some(some_io_operation()); }); match result { Some(err) => { /* hit an I/O error */ } None => { let answer = answer.unwrap(); /* deal with the result of I/O */ } } This pattern can certainly use functions like io::result, but at its core actually handling conditions is fairly difficult * The "zero value" of a function is often confusing. One of the main ideas behind using conditions was to change the signature of I/O functions. Instead of read_be_u32() returning a result, it returned a u32. Errors were notified via a condition, and if you caught the condition you understood that the "zero value" returned is actually a garbage value. These zero values are often difficult to understand, however. One case of this is the read_bytes() function. The function takes an integer length of the amount of bytes to read, and returns an array of that size. The array may actually be shorter, however, if an error occurred. Another case is fs::stat(). The theoretical "zero value" is a blank stat struct, but it's a little awkward to create and return a zero'd out stat struct on a call to stat(). In general, the return value of functions that can raise error are much more natural when using a Result as opposed to an always-usable zero-value. * Conditions impose a necessary runtime requirement on *all* I/O. In theory I/O is as simple as calling read() and write(), but using conditions imposed the restriction that a rust local task was required if you wanted to catch errors with I/O. While certainly an surmountable difficulty, this was always a bit of a thorn in the side of conditions. * Functions raising conditions are not always clear that they are raising conditions. This suffers a similar problem to exceptions where you don't actually know whether a function raises a condition or not. The documentation likely explains, but if someone retroactively adds a condition to a function there's nothing forcing upstream users to acknowledge a new point of task failure. * Libaries using I/O are not guaranteed to correctly raise on conditions when an error occurs. In developing various I/O libraries, it's much easier to just return `None` from a read rather than raising an error. The silent contract of "don't raise on EOF" was a little difficult to understand and threw a wrench into the answer of the question "when do I raise a condition?" Many of these difficulties can be overcome through documentation, examples, and general practice. In the end, all of these difficulties added together ended up being too overwhelming and improving various aspects didn't end up helping that much. A result-based I/O error handling strategy also has shortcomings, but the cognitive burden is much smaller. The tooling necessary to make this strategy as usable as conditions were is much smaller than the tooling necessary for conditions. Perhaps conditions may manifest themselves as a future entity, but for now we're going to remove them from the standard library. Closes #9795 Closes #8968
2014-02-04Register new snapshotsAlex Crichton-5/+0
2014-02-03Fixing remaining warnings and errors throughoutAlex Crichton-18/+9
2014-02-03std: Fixing all documentationAlex Crichton-6/+16
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Remove io::io_errorAlex Crichton-86/+92
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02Remove the SNAP line to work around #11985.Huon Wilson-2/+2
2014-02-02std::fmt: prepare to convert the formatting traits to methods, and workHuon Wilson-0/+35
around the lack of UFCS. The further work is pending a snapshot, to avoid putting #[cfg(stage0)] attributes on all the traits and duplicating them.
2014-02-02std: rename fmt::Default to `Show`.Huon Wilson-8/+27
This is a better name with which to have a #[deriving] mode. Decision in: https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
2014-02-02libextra: Remove `@str` from all the librariesPatrick Walton-1/+0
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-4/+4
2014-01-22Add LowerExp 'e' and UpperExp 'E' format traits/specifiersSiegeLord-0/+30
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-1/+1
from_utf8_owned() behavior
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-1/+1
behavior
2014-01-18Rename iterators for consistencyPalmer Cox-2/+2
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
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-2/+1
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-03Remove std::eitherAlex Crichton-22/+35
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-23Fixing more doc testsAlex Crichton-1/+1
2013-12-23std: Fix all code examplesAlex Crichton-15/+26
2013-12-15std: fix spelling in docs.Huon Wilson-3/+3
2013-12-11Make 'self lifetime illegal.Erik Price-65/+65
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-04std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter.Huon Wilson-1/+1
2013-11-29Removed useless cmp::{min, max} reexports from the integer modulesMarvin Löbel-1/+1
2013-11-29Removed a few macro-expanding-to-module workaroundsMarvin Löbel-22/+17
Also documented a few issues
2013-11-28Register new snapshotsAlex Crichton-10/+10
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-14/+14
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-1/+1
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-2/+4
2013-11-11Move std::rt::io to std::ioAlex Crichton-5/+5
2013-11-05Clarify which errors are format string errorsAlex Crichton-15/+15
There were a few ambiguous error messages which look like they could have cropped up from either the rust compiler for the format string parser. To differentiate, the prefix 'invalid format string' is now added in front of all format string errors. cc #9970
2013-10-23Removed unnecessary comments and white spaces as suggestedreedlepee-5/+3
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-14/+1
2013-10-23Making fields in std and extra : private #4386reedlepee-4/+18
2013-10-21std: Move sys::log_str to repr::repr_to_str. Further work on #2240.Brian Anderson-7/+3
2013-10-19std::fmt: fix markdown peculiarity, unicodify some arrows, ` some trait names.Huon Wilson-14/+14
2013-10-19auto merge of #9932 : alexcrichton/rust/better-fmt-errors, r=cmrbors-24/+27
Instead of just saying "unterminated format string" and friends, instead print information about what was expected and what was found. Closes #9931
2013-10-18Try to improve format! error messagesAlex Crichton-24/+27
Instead of just saying "unterminated format string" and friends, instead print information about what was expected and what was found. Closes #9931
2013-10-18Document traits and Default about format! betterAlex Crichton-3/+48
Closes #9865 Closes #9808
2013-10-17Register new snapshotsAlex Crichton-76/+0
2013-10-15Build a few extra features into format! parsingAlex Crichton-19/+135
* Allow named parameters to specify width/precision * Intepret the format string '0$' as "width is the 0th argument" instead of thinking the lone '0' was the sign-aware-zero-padding flag. To get both you'd need to put '00$' which makes more sense if you want both to happen. Closes #9669
2013-10-15Require module documentation with missing_docAlex Crichton-0/+6
Closes #9824
2013-10-02Check enums in missing_doc lintSteven Fackler-0/+5
Closes #9671
2013-10-01remove the `float` typeDaniel Micay-2/+0
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-10-01auto merge of #9644 : alexcrichton/rust/clarify, r=huonwbors-19/+42
It was a little ambiguous before how explicitl positional parameters and implicit positional parameters intermingled, and this clarifies how the two intermingle. This also updates a little bit of documentation/code examples elsewhere as well.