about summary refs log tree commit diff
path: root/src/libcore/fmt
AgeCommit message (Collapse)AuthorLines
2018-08-24Rollup merge of #53636 - frewsxcv:frewsxcv-nth, r=rkruppekennytm-1/+1
Prefer `.nth(n)` over `.skip(n).next()`. Found by clippy.
2018-08-23Add missing fmt examplesGuillaume Gomez-0/+66
2018-08-23Prefer `.nth(n)` over `.skip(n).next()`.Corey Farwell-1/+1
Found by clippy.
2018-07-25Enforce #![deny(bare_trait_objects)] in src/libcoreljedrz-12/+12
2018-06-26migrate codebase to `..=` inclusive range patternsZack M. Davis-7/+7
These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043).
2018-06-03Reexport fmt::Alignment into stdGuillaume Gomez-2/+1
2018-05-27Stabilize Formatter alignmentGuillaume Gomez-17/+18
2018-05-24Add more missing examples for FormatterGuillaume Gomez-3/+78
2018-05-07Add explanation for #[must_use] on Debug buildersManish Goregaokar-5/+5
2018-05-05Suggest more helpful formatting stringKornel-5/+6
2018-04-26Add more doc aliasesGuillaume Gomez-0/+2
2018-04-20Revert stabilization of `feature(never_type)`.Felix S. Klock II-2/+2
This commit is just covering the feature gate itself and the tests that made direct use of `!` and thus need to opt back into the feature. A follow on commit brings back the other change that motivates the revert: Namely, going back to the old rules for falling back to `()`.
2018-04-13core: Remove an implicit panic from Formatter::padAlex Crichton-1/+5
The expression `&s[..i]` in general can panic if `i` is out of bounds or not on a character boundary for a string, and this caused the codegen for `Formatter::pad` to be a bit larger than it otherwise needed to be. This commit replaces this with `s.get(..i).unwrap_or(&s)` which while having different behavior if `i` is out of bounds has a much smaller code footprint and otherwise avoids the need for `unsafe` code.
2018-04-03tweak fmt::Arguments docsAlex Burka-6/+5
Remove an outdated claim about passing something or other to a function. Also swap the variable names in the example.
2018-03-26Rollup merge of #49103 - glandium:uninitialized, r=cramertjTim Neumann-1/+1
Use an uninitialized buffer in GenericRadix::fmt_int, like in Display::fmt for numeric types The code using a slice of that buffer is only ever going to use bytes that are subsequently initialized.
2018-03-25Rollup merge of #49229 - Centril:doc/format_args_display_debug, r=steveklabnikkennytm-6/+66
Document format_args! / Arguments<'a> behavior wrt. Display and Debug This is a follow up PR to #49067 , this documents the behavior of `format_args!` (i.e: `Argument<'a>`) wrt. `Display` and `Debug`. r? @steveklabnik
2018-03-23Rollup merge of #49102 - glandium:decimal, r=aturonAlex Crichton-5/+0
Remove core::fmt::num::Decimal Before ebf9e1aaf6, it was used for Display::fmt, but ebf9e1aaf6 replaced that with a faster implementation, and nothing else uses it.
2018-03-22document format_args! - fix trailing whitespaceMazdak Farrokhzad-1/+1
2018-03-21document format_args! behavior wrt. Display and DebugMazdak Farrokhzad-6/+66
2018-03-20Rollup merge of #49099 - glandium:master, r=sfacklerkennytm-17/+15
Use associated consts for GenericRadix base and prefix The trait being private, this does not imply an API change.
2018-03-19Auto merge of #48978 - SimonSapin:debug-hex, r=KodrAusbors-2/+14
Add hexadecimal formatting of integers with fmt::Debug This can be used for integers within a larger types which implements Debug (possibly through derive) but not fmt::UpperHex or fmt::LowerHex. ```rust assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]"); assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]"); ``` RFC: https://github.com/rust-lang/rfcs/pull/2226 The new formatting string syntax (`x?` and `X?`) is insta-stable in this PR because I don’t know how to change a built-in proc macro’s behavior based of a feature gate. I can look into adding that, but I also strongly suspect that keeping this feature unstable for a time period would not be useful as possibly no-one would use it during that time. This PR does not add the new (public) `fmt::Formatter` proposed in the API because: * There was some skepticism on response to this part of the RFC * It is not possible to implement as-is without larger changes to `fmt`, because `Formatter` at the moment has no easy way to tell apart for example `Octal` from `Binary`: it only has a function pointer for the relevant `fmt()` method. If some integer-like type outside of `std` want to implement this behavior, another RFC will likely need to propose a different public API for `Formatter`.
2018-03-17Use associated consts for GenericRadix base and prefixMike Hommey-17/+15
2018-03-17Use an uninitialized buffer in GenericRadix::fmt_int, like in Display::fmt ↵Mike Hommey-1/+1
for numeric types The code using a slice of that buffer is only ever going to use bytes that are subsequently initialized.
2018-03-17Remove core::fmt::num::DecimalMike Hommey-5/+0
Before ebf9e1aaf6, it was used for Display::fmt, but ebf9e1aaf6 replaced that with a faster implementation, and nothing else uses it.
2018-03-14Auto merge of #47630 - canndrew:exhaustive-patterns, r=nikomatsakisbors-2/+2
Stabilise feature(never_type). Introduce feature(exhaustive_patterns) This stabilizes `!`, removing the feature gate as well as the old defaulting-to-`()` behavior. The pattern exhaustiveness checks which were covered by `feature(never_type)` have been moved behind a new `feature(exhaustive_patterns)` gate.
2018-03-15Rollup merge of #48970 - GuillaumeGomez:doc-examples, r=QuietMisdreavuskennytm-2/+134
Add missing examples r? @QuietMisdreavus
2018-03-14change never_type stabilisation versionAndrew Cann-2/+2
2018-03-14Fix version numberAndrew Cann-2/+2
2018-03-14stabilise feature(never_type)Andrew Cann-2/+2
Replace feature(never_type) with feature(exhaustive_patterns). feature(exhaustive_patterns) only covers the pattern-exhaustives checks that used to be covered by feature(never_type)
2018-03-13Add hexadecimal formatting of integers with fmt::DebugSimon Sapin-2/+14
This can be used for integers within a larger types which implements Debug (possibly through derive) but not fmt::UpperHex or fmt::LowerHex. ```rust assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]"); assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]"); ``` RFC: https://github.com/rust-lang/rfcs/pull/2226
2018-03-12Add missing examplesGuillaume Gomez-2/+134
2018-03-12Add missing linksGuillaume Gomez-4/+8
2018-02-01Add filter to detect local crates for rustc_on_unimplementedEsteban Küber-6/+11
2018-01-30Changed back inline markings.penpalperson-9/+0
2018-01-28Added inline to fmt for debug implementations of primitives.penpalperson-0/+12
2018-01-08Add missing linksGuillaume Gomez-1/+4
2017-12-20Rollup merge of #46831 - Diggsey:float-debug-fmt, r=dtolnaykennytm-8/+9
Always `Debug` floats with a decimal point Fixes #30967 r? @dtolnay
2017-12-20Auto merge of #46233 - SimonSapin:fmt-debuglist-flags, r=sfacklerbors-43/+79
Make fmt::DebugList and friends forward formatting parameters For example, formatting slice of integers with `{:04?}` should zero-pad each integer. This also affects every use of `#[derive(Debug)]`.
2017-12-19Always print floats with a decimal point with the Debug formatterDiggory Blake-8/+9
2017-12-12Rename never_type_impls gate to never_typeAndrew Cann-2/+2
2017-11-28Reject '2' as a binary digit in internals of 'b' formattingDavid Ross-1/+1
I don't believe the previous code `0 ... 2` would run into any real problems, but it seems confusing to read, given that '2' is never a valid binary digit. As far as I can tell this code is only ever called from within another private method in the trait which has logic to never hand it '2' anyways. I thought we could change this for clarity anyways.
2017-11-28Rollup merge of #46285 - SimonSapin:twos-complement, r=GuillaumeGomezkennytm-0/+20
Document non-obvious behavior of fmt::UpperHex & co for negative integers Before stabilization I’d have suggested changing the behavior, but that time is past.
2017-11-27Keep access to private Formatter fields in Formatter methodsSimon Sapin-43/+49
2017-11-26Document non-obvious behavior of fmt::UpperHex & co for negative integersSimon Sapin-0/+20
Before stabilization I’d have suggested changing the behavior, but that time is past.
2017-11-26Deprecate the Formatter::flags method, fix #46237Simon Sapin-0/+3
2017-11-24Make fmt::DebugList and friends forward formatting parametersSimon Sapin-28/+58
For example, formatting slice of integers with `{:04?}` should zero-pad each integer.
2017-11-22Auto merge of #45198 - oli-obk:fmt_args, r=sfacklerbors-0/+8
Prevent fmt::Arguments from being shared across threads Fixes #45197 This is a **breaking change**! Without doing this it's very easy to create race conditions. There's probably a way to do this without breaking valid use cases, but it would require quite an overhaul of the formatting machinery.
2017-11-21fix some typosMartin Lindhe-1/+1
2017-11-08Add missing example for Debug traitGuillaume Gomez-0/+20
2017-10-11Explain the `_oibit_remover` fieldOliver Schneider-0/+7