about summary refs log tree commit diff
path: root/src/libstd/sys_common/wtf8.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1285/+0
2020-05-31Rollup merge of #72683 - RalfJung:char-debug-check, r=Mark-SimulacrumRalf Jung-4/+2
from_u32_unchecked: check validity, and fix UB in Wtf8 Fixes https://github.com/rust-lang/rust/issues/72760
2020-05-30encode_utf8_raw is not always valid UTF-8; clarify commentsRalf Jung-1/+1
2020-05-30also expose and use encode_utf16_raw for wtf8Ralf Jung-2/+1
2020-05-30wtf8: use encode_utf8_rawRalf Jung-2/+1
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+11
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-04-06Forward OsStr::clone_into to the inner VecJosh Stone-0/+4
Despite OS differences, they're all just `Vec<u8>` inside, so we can just forward `clone_into` calls to that optimized implementation.
2020-03-29Rollup merge of #69937 - TyPR124:osstr_ascii, r=dtolnayDylan DPC-6/+30
ASCII methods on OsStr Would close #69566 I don't know enough about encodings to know if this is a valid change, however the comment on the issue suggests it could be. This does two things: 1. Makes ASCII methods available on OsStr 2. Makes it possible to obtain a `&mut OsStr`. This is necessary to actually use `OsStr::make_ascii_*case` methods since they modify the underlying value. As far as I can tell, the only way to modify a `&mut OsStr` is via the methods I just added. My original hope was to have these methods on `OsStrExt` for Windows, since the standard library already assumes `make_ascii_uppercase` is valid in Windows (see the change I made to windows/process.rs). If it is found these are not valid changes on non-Windows platforms, I can move the methods to the ext trait instead.
2020-03-28ascii methods on osstrTyPR124-6/+30
2020-03-16Fix wrong dereflzutao-2/+2
2020-03-16Use sublice patterns to avoid computing the lenlzutao-12/+4
2020-03-07reduce references on match patterns (clippy::match_ref_pats)Matthias Krüger-4/+4
2019-11-29Format libstd with rustfmtDavid Tolnay-121/+122
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-04-26Use "capacity" as parameter name in with_capacity() methodsMatthias Geier-3/+3
Closes #60271.
2019-04-05Use for_each to extend collectionsJosh Stone-3/+1
This updates the `Extend` implementations to use `for_each` for many collections: `BinaryHeap`, `BTreeMap`, `BTreeSet`, `LinkedList`, `Path`, `TokenStream`, `VecDeque`, and `Wtf8Buf`. Folding with `for_each` enables better performance than a `for`-loop for some iterators, especially if they can just forward to internal iterators, like `Chain` and `FlatMap` do.
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-9/+9
2019-02-28libstd => 2018Taiki Endo-14/+14
2019-02-10libs: doc commentsAlexander Regueiro-5/+5
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-04cleanup: remove static lifetimes from consts in libstdljedrz-1/+1
2018-11-06refactor: use shorthand fieldsteresy-2/+2
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-1/+1
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-06-26migrate codebase to `..=` inclusive range patternsZack M. Davis-6/+6
These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043).
2018-05-09use fmt::Result where applicableAndre Bogus-2/+2
2018-04-21Remove unused methods on the private Wtf8 typeSimon Sapin-14/+0
The type and its direct parent module are `pub`, but they’re not reachable outside of std
2018-03-27Implement `shrink_to` method on collectionsDiggory Blake-0/+5
2018-03-21Deprecate the AsciiExt trait in favor of inherent methodsSimon Sapin-10/+7
The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes https://github.com/rust-lang/rust/issues/39658
2018-03-05while let all the thingsleonardo.yvens-14/+9
2017-12-24Capture environment at spawnDiggory Blake-0/+20
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+1
2017-11-25Implement `Rc`/`Arc` conversions for string-like typesMurarth-0/+14
Provides the following conversion implementations: * `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>` * `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>` * `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-08-13std: Respect formatting flags for str-like OsStrAlex Crichton-3/+7
Historically many `Display` and `Debug` implementations for `OsStr`-like abstractions have gone through `String::from_utf8_lossy`, but this was updated in #42613 to use an internal `Utf8Lossy` abstraction instead. This had the unfortunate side effect of causing a regression (#43765) in code which relied on these `fmt` trait implementations respecting the various formatting flags specified. This commit opportunistically adds back interpretation of formatting trait flags in the "common case" where where `OsStr`-like "thing" is all valid utf-8 and can delegate to the formatting implementation for `str`. This doesn't entirely solve the regression as non-utf8 paths will format differently than they did before still (in that they will not respect formatting flags), but this should solve the regression for all "real world" use cases of paths and such. The door's also still open for handling these flags in the future! Closes #43765
2017-06-15Avoid allocations in Debug for os_strStepan Koltsov-4/+42
Fixes #38879
2017-05-05Update documention in windows::ffiDavid LeGare-0/+1
2017-03-15Auto merge of #40009 - clarcharr:box_to_buf, r=alexcrichtonbors-0/+6
Leftovers from #39594; From<Box> impls These are a few more impls that follow the same reasoning as those from #39594. What's included: * `From<Box<str>> for String` * `From<Box<[T]>> for Vec<T>` * `From<Box<CStr>> for CString` * `From<Box<OsStr>> for OsString` * `From<Box<Path>> for PathBuf` * `Into<Box<str>> for String` * `Into<Box<[T]>> for Vec<T>` * `Into<Box<CStr>> for CString` * `Into<Box<OsStr>> for OsString` * `Into<Box<Path>> for PathBuf` * `<Box<CStr>>::into_c_string` * `<Box<OsStr>>::into_os_string` * `<Box<Path>>::into_path_buf` * Tracking issue for latter three methods + three from previous PR. Currently, the opposite direction isn't doable with `From` (only `Into`) because of the separation between `liballoc` and `libcollections`. I'm holding off on those for a later PR.
2017-03-10Add From<Box<..>> implementations.Clar Charr-0/+6
2017-03-10OsString::shrink_to_fit.Clar Charr-0/+5
2017-02-14Conversions between CStr/OsStr/Path and boxes.Clar Charr-0/+19
2016-11-01std: Move sys_common to libstd/sys_commonBrian Anderson-0/+1180
Make the directory structure reflect the module structure. I've always found the existing structure confusing.