about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2020-07-20Auto merge of #74010 - pierwill:pierwill-o-notation, r=GuillaumeGomezbors-35/+35
Use italics for O notation In documentation, I think it makes sense to italicize O notation (*O(n)*) as opposed to using back-ticks (`O(n)`). Visually, back-ticks focus the reader on the literal characters being used, making them ideal for representing code. Using italics, as far I can tell, more closely follows typographic conventions in mathematics and computer science. Just a suggestion, of course! 😇
2020-07-19Use italics for O notationpierwill-35/+35
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2020-07-18Clarify the literal stringManish Goregaokar-1/+1
2020-07-18Use intra-doc links in BTreeMapManish Goregaokar-21/+12
2020-07-18Use more intra-doc links in BTreeSetManish Goregaokar-3/+3
2020-07-18Use intra-doc links in alloc::StringManish Goregaokar-100/+47
2020-07-17Rollup merge of #74453 - Manishearth:intra-doc-std, r=jyn514Manish Goregaokar-15/+7
Use intra-doc links in `str` and `BTreeSet` Fixes #32129, fixes #32130 A _slight_ degradation in quality is that the `#method.foo` links would previously link to the same page on `String`'s documentation, and now they will navigate to `str`. Not a big deal IMO, and we can also try to improve that.
2020-07-17Use intra-doc links in BTreeSet docsManish Goregaokar-15/+7
2020-07-17Fix Arc::as_ptr docsAbendstolz-1/+1
As a none-native speaker I stumbled upon this, looked it up and couldn't find a phrase, so I made my own assumption that "in any way" was meant (which is the meaning I would've deduced anyway)
2020-07-17Auto merge of #74395 - Mark-Simulacrum:stage0-next, r=pietroalbinibors-1/+0
Bump version to 1.47 This also bumps to a more recent rustfmt version, just to keep us relatively up to date (though almost nothing has changed in rustfmt we use beyond bumps to the parser infra). No formatting changes as a result of this. r? @pietroalbini
2020-07-16apply bootstrap cfgsMark Rousskov-1/+0
2020-07-16Separate off BTreeMap support functions and loose their irrelevant boundsStein Somers-59/+61
2020-07-16Clean up or comment every unwrap in BTreeMap's main code.Stein Somers-46/+40
2020-07-16Rollup merge of #74295 - ssomers:btree_comments, r=Mark-SimulacrumManish Goregaokar-18/+25
Add and fix BTreeMap comments No code changed (yet)
2020-07-14Remove unnecessary type hints from the Wake implYoshua Wuyts-3/+2
2020-07-13Add and fix BTreeMap commentsStein Somers-18/+25
2020-07-10Rollup merge of #74099 - jonhoo:deque-range, r=dtolnayManish Goregaokar-13/+163
Add VecDeque::range* methods This patch adds `VecDeque::range` and `VecDeque::range_mut` to provide iterators over a sub-range of a `VecDeque`. This behavior can be emulated with `skip` and `take`, but directly providing a `Range` is more ergonomic. This also partially makes up for `VecDeque`'s lack of `SliceIndex` support.
2020-07-10Add tracking issueJon Gjengset-2/+2
2020-07-09Rollup merge of #74143 - pickfire:patch-2, r=jonas-schievinkManish Goregaokar-2/+0
Try remove unneeded ToString import in liballoc slice
2020-07-08Remove unneeded ToString import in liballoc sliceIvan Tham-2/+0
2020-07-08Liballoc use vec instead of vectorIvan Tham-3/+3
Keep congruency with other parts, full word vector is rarely used.
2020-07-06Rollup merge of #73974 - CAD97:rc-no-weak, r=dtolnayManish Goregaokar-2/+2
Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr) These were stabilized alongside the Weak versions, but having `feature = "weak_.."` on a fn definition for the non-weak pointers is potentially very misleading, especially in a review context where the impl header may not be immediately visible. r? @RalfJung @bors rollup=always
2020-07-06fixupsJon Gjengset-4/+9
2020-07-06Add VecDeque::range* methodsJon Gjengset-13/+158
This patch adds `VecDeque::range` and `VecDeque::range_mut` to provide iterators over a sub-range of a `VecDeque`. This behavior can be emulated with `skip` and `take`, but directly providing a `Range` is more ergonomic. This also partially makes up for `VecDeque`'s lack of `SliceIndex` support.
2020-07-05Rollup merge of #74025 - tmiasko:try-unwrap, r=AmanieuManish Goregaokar-2/+1
Remove unnecessary release from Arc::try_unwrap The thread that recovers the unique access to Arc inner value (e.g., drop when ref-count strong reaches zero, successful try_unwrap), ensures that other operations on Arc inner value happened before by synchronizing with release operations performed when decrementing the reference counter. When try_unwrap succeeds, the current thread recovers the unique access to Arc inner value, so release is unnecessary. r? @Amanieu
2020-07-05Rollup merge of #72688 - djugei:master, r=AmanieuManish Goregaokar-0/+16
added .collect() into String from Box<str> I have not created an rfc, because i felt like this is a very minor change. i have just set a random feature name and rust version as stability attribute, i expect to have to change that, i just don't know what the policy on that is. all guides i could find focused on contributing to the compiler, not contributing to the standard library. drawbacks: more code in the standard library, could be replaced with specialization: base-implementation for AsRef\<str> and specialization for String and Cow. i can write that code if ppl want it. advantages: using "real strings" i.e. Box\<str> is as ergonomic as string slices (&str) and string buffers (String) with iterators.
2020-07-04Remove unnecessary release from Arc::try_unwrapTomasz MiÄ…sko-2/+1
The thread that recovers the unique access to Arc inner value (e.g., drop when ref-count strong reaches zero, successful try_unwrap), ensures that other operations on Arc inner value happened before by synchronizing with release operations performed when decrementing the reference counter. When try_unwrap succeeds, the current thread recovers the unique access to Arc inner value, so release is unnecessary.
2020-07-03Rollup merge of #73845 - CAD97:weak-as-unsized-ptr, r=RalfJungManish Goregaokar-44/+59
Use &raw in A|Rc::as_ptr This PR uses `&raw` for offsetting `*mut [A]RcInner<T> -> *mut T`. Additionally, this updates the implementation of `Weak::as_ptr` to support unsized `T`, though it does not yet relax the bounds of `Weak::as_ptr`/`into_raw`/`from_raw` to accept unsized `T`.
2020-07-03Auto merge of #73882 - nnethercote:avoid-unwrap_or_else-in-allocate_in, ↵bors-3/+14
r=Amanieu Avoid `unwrap_or_else` in `RawVec::allocate_in`. This reduces the amount of LLVM IR generated by up to 1 or 2%. r? @Amanieu
2020-07-02Note Weak.ptr never dangles soonerCAD97-0/+2
2020-07-02Move A|Rc::as_ptr from feature(weak_into_raw)CAD97-2/+2
to feature(rc_as_ptr) These were stabilized alongside the Weak versions, but having `feature = "weak_.."` on a fn definition for the non-weak pointers is potentially very confusing.
2020-07-02disable BTree min_max test in Miri for nowRalf Jung-0/+1
2020-07-01Reclarify safety comments in Weak::as_ptrCAD97-6/+6
2020-07-01Simplify Weak::as_ptr implCAD97-6/+4
2020-07-01Apply documentation review suggestionsCAD97-6/+8
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-07-01Rollup merge of #73678 - Keno:patch-1, r=LukasKalbertodtManish Goregaokar-1/+4
Update Box::from_raw example to generalize better I know very little about rust, so I saw the example here ``` use std::alloc::{alloc, Layout}; unsafe { let ptr = alloc(Layout::new::<i32>()) as *mut i32; *ptr = 5; let x = Box::from_raw(ptr); } ``` and tried to generalize it by writing, ``` let layout = Layout::new::<T>(); let new_obj = unsafe { let ptr = alloc(layout) as *mut T; *ptr = obj; Box::from_raw(ptr) }; ``` for some more complicated `T`, which ended up crashing with SIGSEGV, because it tried to `drop_in_place` the previous object in `ptr` which is of course garbage. I think that changing this example to use `.write` instead would be a good idea to suggest the correct generalization. It is also more consistent with other documentation items in this file, which use `.write`. I also added a comment to explain it, but I'm not too attached to that, and can see it being too verbose in this place.
2020-07-01Rollup merge of #73466 - matthiaskrgr:char_into_string, r=dtolnayManish Goregaokar-0/+15
impl From<char> for String This allows us to write ````rust fn char_to_string() -> String { 'a'.into() } ```` which was not possible before.
2020-06-30Clarify when rc::data_offset is safeCAD97-1/+20
2020-06-30Fix invalid pointer deref in Weak::as_ptrCAD97-2/+2
2020-06-30Clarify safety comment for A|Rc::as_ptrCAD97-10/+6
2020-06-30Avoid `unwrap_or_else` in `RawVec::allocate_in`.Nicholas Nethercote-3/+14
This reduces the amount of LLVM IR generated by up to 1 or 2%.
2020-06-29Auto merge of #73391 - pickfire:liballoc-panic-doc, r=Mark-Simulacrumbors-11/+5
Add liballoc doc panic detail according to RawVec
2020-06-28Use impl for Weak::as_ptr that works for unsized TCAD97-22/+26
2020-06-28Do not require ptr validity in rc::data_offsetCAD97-2/+3
2020-06-28Use raw_ref_op in A|Rc::as_ptrCAD97-10/+3
2020-06-28Remove `const_if_match` feature gate from librariesDylan MacKenzie-1/+1
2020-06-26Rollup merge of #73765 - kraai:remove-blank-line, r=jonas-schievinkManish Goregaokar-1/+0
Remove blank line
2020-06-26Rollup merge of #73627 - ssomers:btree_iter_min_max, r=Mark-SimulacrumManish Goregaokar-0/+141
Shortcuts for min/max on double-ended BTreeMap/BTreeSet iterators Closes #59947: a performance tweak that might benefit some. Optimizes `min` and `max ` on all btree double-ended iterators that do not drop, i.e. the iterators created by: - `BTreeMap::iter` - `BTreeMap::iter_mut` - `BTreeMap::keys` and `BTreeSet::iter` - `BTreeMap::range` and `BTreeSet::range` - `BTreeMap::range_mut` Also in these (currently) single-ended iterators, but obviously for `min` only: - `BTreeSet::difference` - `BTreeSet::intersection` - `BTreeSet::symmetric_difference` - `BTreeSet::union` Did not do this in iterators created by `into_iter` to preserve drop order, as outlined in #62316. Did not do this in iterators created by `drain_filter`, possibly to preserve drop order, possibly to preserve predicate invocation, mostly to not have to think about it too hard (I guess maybe it wouldn't be a change for `min`, which is the only shortcut possible in this single-ended iterator).
2020-06-26Rollup merge of #73529 - pickfire:liballoc-specfromelem-i8, r=cuviperManish Goregaokar-1/+15
Add liballoc impl SpecFromElem for i8 Speedup vec![1_i8; N] for non-zero element. Before test do_bench_from_elem_i8 ... bench: 130 ns/iter (+/- 7) = 61 MB/s test do_bench_from_elem_u8 ... bench: 121 ns/iter (+/- 4) = 66 MB/s After test do_bench_from_elem_i8 ... bench: 123 ns/iter (+/- 7) = 65 MB/s test do_bench_from_elem_u8 ... bench: 121 ns/iter (+/- 5) = 66 MB/s No speed difference if element is already zero. ```rust #[bench] fn do_bench_from_elem_i8(b: &mut Bencher) { b.bytes = 8 as u64; b.iter(|| { let dst = ve::vec![10_i8; 100]; assert_eq!(dst.len(), 100); assert!(dst.iter().all(|x| *x == 10)); }) } ``` As suggested by @cuviper https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/SpecForElem.20for.20other.20integers r? @cuviper CC @joshtriplett Edit: Wow, I just realized both reviewers are Josh.
2020-06-27Add liballoc doc panic detail according to RawVecIvan Tham-11/+5