summary refs log tree commit diff
path: root/src/libcore/fmt
AgeCommit message (Collapse)AuthorLines
2017-04-20Remove num::{Zero,One}Josh Stone-2/+3
[unstable, deprecated since 1.11.0]
2017-04-09Added doc comments for fmt::Resultmandeep-1/+24
2017-03-15Change how the 0 flag works in format! for floatsPiotr Jawniak-1/+4
Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. :06 :<06 :>06 :^06 before |-001.2| |-1.200| |-001.2| |-01.20| after |-001.2| |-001.2| |-001.2| |-001.2|
2017-03-15Change how the `0` flag works in format!Piotr Jawniak-0/+1
Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits. :05 :<05 :>05 :^05 before |-0001| |-1000| |-0001| |-0100| after |-0001| |-0001| |-0001| |-0001| :#05x :<#05x :>#05x :^#05x before |0x001| |0x100| |000x1| |0x010| after |0x001| |0x001| |0x001| |0x001| Fixes #39997 [breaking-change]
2017-03-10Add missing example for Display::fmtGuillaume Gomez-1/+20
2017-02-28Add missing docs and examples for fmt::WriteGuillaume Gomez-9/+62
2017-02-12Fix some typos in the core::fmt docs.Ahmed Charles-2/+2
2017-02-09name anonymous fn parameters in libcore traitsTrevor Spiteri-9/+9
2017-02-07Improve fmt floatSon-83/+98
* Move to a separate float mod * Add more tests for f64 f32 lower exp upper exp * Use assert_eq for a clearer error message
2017-02-03Auto merge of #39463 - alexcrichton:update-bootstrap, r=alexcrichtonbors-7/+1
Bump version, upgrade bootstrap This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03Bump version, upgrade bootstrapAlex Crichton-7/+1
This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-02remove the wrapping arithmeticsMichał Krasnoborski-10/+5
2017-02-01Adjust heuristics to better handle "{}..." format strings.Michał Krasnoborski-9/+12
2017-01-28use `String::with_capacity` in `format!`Michał Krasnoborski-0/+28
2016-12-3040 -> 39, as ceil(log10(2^128)) == 39est31-1/+1
just as ceil(log10(2^64)) == 20
2016-12-30Such large. Very 128. Much bits.Simonas Kazlauskas-5/+16
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which understands and supports 128-bit integers throughout. The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported, this strategy is good enough to get past the first bootstrap stages to end up with a fully working 128-bit capable compiler. In order for this strategy to work, number of locations had to be changed to use associated max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?) had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works (former not necessarily producing the right results in stage1). This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-16Address falloutAaron Turon-5/+5
2016-11-28Make core::fmt::Void a non-empty type.Andrew Cann-1/+3
Because we handle artifically-constructed references to it in live code which is a totally broken thing to do.
2016-10-27tidy/features: fix checking of lang featuresTamir Duberstein-2/+2
Removes the `STATUSES` static which duplicates truth from the pattern match in `collect_lang_features`. Fixes existing duplicates by renaming: - never_type{,_impls} on `impl`s on `!` - concat_idents{,_macro} on `macro_rules! concat_idents` Fixes #37013.
2016-10-01impl Debug for raw pointers to unsized dataAlex Burka-2/+2
2016-09-30Rollup merge of #36535 - GuillaumeGomez:macro_url, r=steveklabnikSteve Klabnik-2/+2
Update to new macro url syntax r? @steveklabnik
2016-09-28[breaking-change] std: change `encode_utf{8,16}()` to take a buffer and ↵tormol-13/+5
return a slice They panic if the buffer is too small.
2016-09-22Rollup merge of #36423 - GuillaumeGomez:eq_impl, r=pnkfelixJonathan Turner-1/+1
Add missing Eq implementations Part of #36301.
2016-09-18Add missing Eq implementationsGuillaume Gomez-1/+1
2016-09-16Add links between format_args! macro and std::fmt::Arguments structMark-Simulacrum-3/+7
2016-09-16Update to new macro url syntaxGuillaume Gomez-2/+2
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-8/+0
2016-08-19Remove old stage0 compatibilityBrian Anderson-19/+10
2016-08-13Rename empty/bang to neverAndrew Cann-2/+2
Split Ty::is_empty method into is_never and is_uninhabited
2016-08-13Minor fixups based on @eddyb's feedbackAndrew Cann-2/+2
Mainly, remove mk_empty() method and replace with tcx.types.empty
2016-08-13impl Debug + Display for !Andrew Cann-0/+23
2016-07-28Rename `char::escape` to `char::escape_debug` and add tracking issueTobias Bucher-2/+2
2016-07-26Restore `char::escape_default` and add `char::escape` insteadTobias Bucher-2/+2
2016-07-21Auto merge of #34544 - ↵bors-7/+11
3Hren:issue/xx/reinterpret-format-precision-for-strings, r=alexcrichton feat: reinterpret `precision` field for strings This commit changes the behavior of formatting string arguments with both width and precision fields set. Documentation says that the `width` field is the "minimum width" that the format should take up. If the value's string does not fill up this many characters, then the padding specified by fill/alignment will be used to take up the required space. This is true for all formatted types except string, which is truncated down to `precision` number of chars and then all of `fill`, `align` and `width` fields are completely ignored. For example: `format!("{:/^10.8}", "1234567890);` emits "12345678". In the contrast Python version works as the expected: ```python >>> '{:/^10.8}'.format('1234567890') '/12345678/' ``` This commit gives back the `Python` behavior by changing the `precision` field meaning to the truncation and nothing more. The result string *will* be prepended/appended up to the `width` field with the proper `fill` char. __However, this is the breaking change, I admit.__ Feel free to close it, but otherwise it should be mentioned in the `std::fmt` documentation somewhere near of `fill/align/width` fields description.
2016-07-06feat: reinterpret `precision` field for stringsEvgeny Safronov-7/+11
This commit changes the behavior of formatting string arguments with both width and precision fields set. Documentation says that the `width` field is the "minimum width" that the format should take up. If the value's string does not fill up this many characters, then the padding specified by fill/alignment will be used to take up the required space. This is true for all formatted types except string, which is truncated down to `precision` number of chars and then all of `fill`, `align` and `width` fields are completely ignored. For example: `format!("{:/^10.8}", "1234567890);` emits "12345678". In the contrast Python version works as the expected: ```python >>> '{:/^10.8}'.format('1234567890') '/12345678/' ``` This commit gives back the `Python` behavior by changing the `precision` field meaning to the truncation and nothing more. The result string *will* be prepended/appended up to the `width` field with the proper `fill` char. However, this is the breaking change. Also updated `std::fmt` docs about string precision. Signed-off-by: Evgeny Safronov <division494@gmail.com>
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-5/+2
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-23Use `len` instead of `size_hint` where appropiateTobias Bucher-1/+1
This makes it clearer that we're not just looking for a lower bound but rather know that the iterator is an `ExactSizeIterator`.
2016-06-03Auto merge of #33460 - shepmaster:16-bit-pointers, r=Aatchbors-0/+4
Support 16-bit pointers as well as i/usize I'm opening this pull request to get some feedback from the community. Although Rust doesn't support any platforms with a native 16-bit pointer at the moment, the [AVR-Rust][ar] fork is working towards that goal. Keeping this forked logic up-to-date with the changes in master has been onerous so I'd like to merge these changes so that they get carried along when refactoring happens. I do not believe this should increase the maintenance burden. This is based on the original work of Dylan McKay (@dylanmckay). [ar]: https://github.com/avr-rust/rust
2016-05-23Add explanations about what derived trait implementations doCarol (Nichols || Goulding)-1/+5
2016-05-19Support 16-bit pointers as well as i/usizeJake Goulding-0/+4
This is based on the original work of Dylan McKay for the [avr-rust project][ar]. [ar]: https://github.com/avr-rust/rust
2016-05-10Doc improvement on std::fmt moduleGuillaume Gomez-0/+26
2016-04-16Auto merge of #32909 - sanxiyn:unused-trait-import-2, r=alexcrichtonbors-1/+1
Remove unused trait imports
2016-04-15Implement `Default` for more types in the standard libraryTobias Bucher-1/+1
Also add `Hash` to `std::cmp::Ordering` and most possible traits to `fmt::Error`.
2016-04-12Remove unused trait importsSeo Sanghyeon-1/+1
2016-03-22try! -> ?Jorge Aparicio-30/+30
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-22std: Change `encode_utf{8,16}` to return iteratorsAlex Crichton-14/+13
Currently these have non-traditional APIs which take a buffer and report how much was filled in, but they're not necessarily ergonomic to use. Returning an iterator which *also* exposes an underlying slice shouldn't result in any performance loss as it's just a lazy version of the same implementation, and it's also much more ergonomic! cc #27784
2016-03-20libcore: add Debug implementations to most missing typesSean McArthur-4/+28
2016-03-12std: Clean out deprecated APIsAlex Crichton-111/+12
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that are deprecated in the 1.8 release are sticking around for the rest of this cycle. Some notable changes are: * The `dynamic_lib` module was moved into `rustc_back` as the compiler still relies on a few bits and pieces. * The `DebugTuple` formatter now special-cases an empty struct name with only one field to append a trailing comma.
2016-03-08std: Fix rustdoc links with std::fmt::AlignmentAlex Crichton-12/+33
This is actually a reexported implementation detail in the `rt::v1` module but rustdoc doesn't like reexporting items from `doc(hidden)` modules. Do what we'd end up doing anyway from an API perspective and make a public-facing `enum` that can be retranslated under the hood if necessary.
2016-03-04End stdlib module summaries with a full stop.Steve Klabnik-1/+1
Fixes #9447