about summary refs log tree commit diff
path: root/library/std/src/ffi
AgeCommit message (Collapse)AuthorLines
2021-08-24Fix typo “a Rc” → “an Rc”Frank Steffahn-2/+2
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-08-22Fix more “a”/“an” typosFrank Steffahn-2/+2
2021-08-22Fix typos “a”→“an”Frank Steffahn-6/+6
2021-08-08Auto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnaybors-2/+1
Stabilize Vec<T>::shrink_to This PR stabilizes `shrink_to` feature and closes the corresponding issue. The second point was addressed already, and no `panic!` should occur. Closes #56431.
2021-08-08Bump shrink_to stabilization to Rust 1.56David Tolnay-1/+1
2021-08-05alloc: Use intra doc links for the reserve functionest31-1/+3
The sentence exists to highlight the existence of a performance footgun of repeated calls of the reserve_exact function.
2021-07-06Stabilize Vec<T>::shrink_toYoh Deadfall-2/+1
2021-06-30Remove "length" doc aliasesAmanieu d'Antras-1/+0
2021-06-23Use HTTPS links where possibleSmitty-2/+2
2021-05-26Add inline attr to private CString::into_innerElichai Turkel-0/+1
2021-05-20Rollup merge of #85275 - CDirkx:memchr, r=m-ou-seGuillaume Gomez-1/+1
Move `std::memchr` to `sys_common` `std::memchr` is a thin abstraction over the different `memchr` implementations in `sys`, along with documentation and tests. The module is only used internally by `std`, nothing is exported externally. Code like this is exactly what the `sys_common` module is for, so this PR moves it there.
2021-05-18Add diagnostic item to `CStr`Mateusz Gacek-0/+1
2021-05-17Simplify `cfg(any(unix, target_os="redox"))` to just `cfg(unix)`Christiaan Dirkx-1/+1
2021-05-14Move `std::memchr` to `sys_common`Christiaan Dirkx-1/+1
2021-05-02Change 'NULL' to 'null'Brent Kerby-1/+1
2021-04-27Override `clone_from` method for PathBuf and OsStringBenoît du Garreau-1/+13
2021-03-31Add a few missing links, fix a typoFrank Steffahn-1/+1
2021-03-31Fix documentation of conversion from String to OsStringFrank Steffahn-1/+1
2021-03-29ffi::c_str smaller as_bytesklensy-2/+4
2021-03-28ffi::c_str added tests for empty stringsklensy-0/+16
2021-03-24Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisaDylan DPC-1/+1
Add internal io::Error::new_const to avoid allocations. This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`. The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.) See https://github.com/rust-lang/rust/issues/83352
2021-03-22Rollup merge of #80193 - zseri:stabilize-osstring-ascii, r=m-ou-seDylan DPC-12/+6
stabilize `feature(osstring_ascii)` This PR stabilizes `feature(osstring_ascii)`. Fixes #70516.
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-1/+1
2021-03-21Bump osstring_ascii stabilization version to 1.53.0.Mara Bos-6/+6
2021-03-14Rollup merge of #82121 - lopopolo:pathbuf-osstring-extend, r=joshtriplettYuki Okushi-0/+86
Implement Extend and FromIterator for OsString Add the following trait impls: - `impl Extend<OsString> for OsString` - `impl<'a> Extend<&'a OsStr> for OsString` - `impl FromIterator<OsString> for OsString` - `impl<'a> FromIterator<&'a OsStr> for OsString` Because `OsString` is a platform string with no particular semantics, concatenating them together seems acceptable. I came across a use case for these trait impls in https://github.com/artichoke/artichoke/pull/1089: Artichoke is a Ruby interpreter. Its CLI accepts multiple `-e` switches for executing inline Ruby code, like: ```console $ cargo -q run --bin artichoke -- -e '2.times {' -e 'puts "foo: #{__LINE__}"' -e '}' foo: 2 foo: 2 ``` I use `clap` for command line argument parsing, which collects these `-e` commands into a `Vec<OsString>`. To pass these commands to the interpreter for `Eval`, I need to join them together. Combining these impls with `Iterator::intersperse` https://github.com/rust-lang/rust/issues/79524 would enable me to build a single bit of Ruby code. Currently, I'm doing something like: ```rust let mut commands = commands.into_iter(); let mut buf = if let Some(command) = commands.next() { command } else { return Ok(Ok(())); }; for command in commands { buf.push("\n"); buf.push(command); } ``` If there's interest, I'd also like to add impls for `Cow<'a, OsStr>`, which would avoid allocating the `"\n"` `OsString` in the concatenate + intersperse use case.
2021-03-05stabilize feature(osstring_ascii)zseri-12/+6
2021-03-03Add impls for iterators of Cow<OsStr>Ryan Lopopolo-0/+34
2021-02-25Convert primitives to use intra-doc linksJoshua Nelson-4/+2
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+2
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-16Optimize FromIterator<OsString> to reuse the first allocationRyan Lopopolo-4/+11
2021-02-16a few more diagnostic itemsAndrea Nall-0/+1
2021-02-15requested/proposed changesAndrea Nall-1/+1
2021-02-15add diagnostic itemsAndrea Nall-0/+1
Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-14Implement Extend and FromIterator for OsStringRyan Lopopolo-0/+45
Add the following trait impls: - `impl Extend<OsString> for OsString` - `impl<'a> Extend<&'a OsStr> for OsString` - `impl FromIterator<OsString> for OsString` - `impl<'a> FromIterator<&'a OsStr> for OsString` Because `OsString` is a platform string with no particular semantics, concatenating them together seems acceptable.
2021-02-10Seal the CommandExt, OsStrExt and OsStringExt traitsAmanieu d'Antras-0/+8
2021-02-03OsStr eq_ignore_ascii_case takes arg by valueTyler Ruckinger-1/+1
Per a comment on #70516 this changes `eq_ignore_ascii_case` to take the generic parameter `S: AsRef<OsStr>` by value instead of by reference. This is technically a breaking change to an unstable method. I think the only way it would break is if you called this method with an explicit type parameter, ie `my_os_str.eq_ignore_ascii_case::<str>("foo")` becomes `my_os_str.eq_ignore_ascii_case::<&str>("foo")`. Besides that, I believe it is overall more flexible since it can now take an owned `OsString` for example. If this change should be made in some other PR (like #80193) then please just close this.
2021-01-26shrink_to shouldn't panic on len greater than capacityThom Wiggers-2/+1
2021-01-22Inline methods of Path and OsStringBenoît du Garreau-0/+34
2021-01-13Update tests for extern block lintingMark Rousskov-7/+7
2020-12-28Add "length" as doc alias to len methodsKonrad Borowski-0/+1
2020-12-16Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnaybors-2/+2
Refactor and fix `parse_prefix` on Windows This PR is an extension of #78692 as well as a general refactor of `parse_prefix`: **Fixes**: There are two errors in the current implementation of `parse_prefix`: Firstly, in the current implementation only `\` is recognized as a separator character in device namespace prefixes. This behavior is only correct for verbatim paths; `"\\.\C:/foo"` should be parsed as `"C:"` instead of `"C:/foo"`. Secondly, the current implementation only handles single separator characters. In non-verbatim paths a series of separator characters should be recognized as a single boundary, e.g. the UNC path `"\\localhost\\\\\\C$\foo"` should be parsed as `"\\localhost\\\\\\C$"` and then `UNC(server: "localhost", share: "C$")`, but currently it is not parsed at all, because it starts being parsed as `\\localhost\` and then has an invalid empty share location. Paths like `"\\.\C:/foo"` and `"\\localhost\\\\\\C$\foo"` are valid on Windows, they are equivalent to just `"C:\foo"`. **Refactoring**: All uses of `&[u8]` within `parse_prefix` are extracted to helper functions and`&OsStr` is used instead. This reduces the number of places unsafe is used: - `get_first_two_components` is adapted to the more general `parse_next_component` and used in more places - code for parsing drive prefixes is extracted to `parse_drive`
2020-11-19Bump bootstrap compiler versionJake Goulding-1/+1
2020-11-07Refactor `parse_prefix` on WindowsChristiaan Dirkx-2/+2
Refactor `get_first_two_components` to `get_next_component`. Fixes the following behaviour of `parse_prefix`: - series of separator bytes in a prefix are correctly parsed as a single separator - device namespace prefixes correctly recognize both `\\` and `/` as separators
2020-10-26Fix bootstrap doctest failureNathan Whitaker-1/+1
2020-10-26Address review commentsNathan Whitaker-1/+0
2020-10-26Address review commentsNathan Whitaker-0/+2
2020-10-26Change to warn by default / fix typoNathan Whitaker-1/+1
2020-10-26Update doctestNathan Whitaker-1/+1
2020-10-15Deny broken intra-doc links in linkcheckerJoshua Nelson-1/+2
Since rustdoc isn't warning about these links, check for them manually.