| Age | Commit message (Collapse) | Author | Lines |
|
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! 😇
|
|
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
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)
|
|
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
|
|
|
|
|
|
|
|
Add and fix BTreeMap comments
No code changed (yet)
|
|
|
|
|
|
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.
|
|
|
|
Try remove unneeded ToString import in liballoc slice
|
|
|
|
Keep congruency with other parts, full word vector is rarely used.
|
|
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
|
|
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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`.
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
|
|
Co-Authored-By: Ralf Jung <post@ralfj.de>
|
|
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.
|
|
impl From<char> for String
This allows us to write
````rust
fn char_to_string() -> String {
'a'.into()
}
````
which was not possible before.
|
|
|
|
|
|
|
|
This reduces the amount of LLVM IR generated by up to 1 or 2%.
|
|
Add liballoc doc panic detail according to RawVec
|
|
|
|
|
|
|
|
|
|
Remove blank line
|
|
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).
|
|
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.
|
|
|