Skip to content

Rollup of 8 pull requests #85838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
53bf79e
Do not try to build LLVM with Zlib on Windows
mati865 May 27, 2021
8b6dad2
Remove `--print unversioned-files` from rustdoc
Bobo1239 May 28, 2021
23f9b92
Add `String::extend_from_within`
WaffleLapkin May 29, 2021
2f1372b
Add documentation for aarch64-apple-ios-sim target
badboy May 28, 2021
aa1b127
tier-check: Check for lines with '[' such as those containing links
badboy May 28, 2021
d874ecc
Use correct edition when parsing `:pat` matchers
Aaron1011 May 26, 2021
8d70f40
Fix a typo
May 29, 2021
b237f90
Don't drop `PResult` without handling the error
LeSeulArtichaut May 29, 2021
b4148e9
Add eslint checks in CI
GuillaumeGomez May 14, 2021
558b073
Fix eslint error in sidebar-items.js
GuillaumeGomez May 30, 2021
9c873c1
Rollup merge of #85285 - GuillaumeGomez:eslint-check, r=jsha,Mark-Sim…
GuillaumeGomez May 30, 2021
bdd7062
Rollup merge of #85709 - Aaron1011:fix-pat-crate-edition, r=petrochenkov
GuillaumeGomez May 30, 2021
957badb
Rollup merge of #85762 - mati865:disable-zlib-on-windows, r=Mark-Simu…
GuillaumeGomez May 30, 2021
f7fb29b
Rollup merge of #85770 - Bobo1239:set_locale_for_sort, r=jyn514
GuillaumeGomez May 30, 2021
2d30bc7
Rollup merge of #85781 - badboy:document-aarch-ios-sim-support, r=Ama…
GuillaumeGomez May 30, 2021
b0f2a4c
Rollup merge of #85801 - WaffleLapkin:master, r=joshtriplett
GuillaumeGomez May 30, 2021
980a4a7
Rollup merge of #85817 - r00ster91:patch-9, r=dtolnay
GuillaumeGomez May 30, 2021
71a7f8f
Rollup merge of #85818 - LeSeulArtichaut:85794-diag-drop-ice, r=petro…
GuillaumeGomez May 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add String::extend_from_within
This patch adds `String::extend_from_within` function under the
`string_extend_from_within` feature gate similar to the
`Vec::extend_from_within` function.
  • Loading branch information
WaffleLapkin committed May 29, 2021
commit 23f9b92c5e3fd6dcff19fb185b64990f0336a8bf
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
#![feature(associated_type_bounds)]
#![feature(slice_group_by)]
#![feature(decl_macro)]
#![feature(bindings_after_at)]
// Allow testing this library

#[cfg(test)]
Expand Down
36 changes: 36 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,42 @@ impl String {
self.vec.extend_from_slice(string.as_bytes())
}

/// Copies elements from `src` range to the end of the string.
///
/// ## Panics
///
/// Panics if the starting point or end point do not lie on a [`char`]
/// boundary, or if they're out of bounds.
///
/// ## Examples
///
/// ```
/// #![feature(string_extend_from_within)]
/// let mut string = String::from("abcde");
///
/// string.extend_from_within(2..);
/// assert_eq!(string, "abcdecde");
///
/// string.extend_from_within(..2);
/// assert_eq!(string, "abcdecdeab");
///
/// string.extend_from_within(4..8);
/// assert_eq!(string, "abcdecdeabecde");
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "string_extend_from_within", issue = "none")]
pub fn extend_from_within<R>(&mut self, src: R)
where
R: RangeBounds<usize>,
{
let src @ Range { start, end } = slice::range(src, ..self.len());

assert!(self.is_char_boundary(start));
assert!(self.is_char_boundary(end));

self.vec.extend_from_within(src);
}

/// Returns this `String`'s capacity, in bytes.
///
/// # Examples
Expand Down