Skip to content

Commit cb7f033

Browse files
authored
Bump to 3.20.0 (#307)
* Small clean ups and formatting * Bump to version 3.20.0 * fmt
1 parent d97d31c commit cb7f033

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Released YYYY-MM-DD.
2828

2929
--------------------------------------------------------------------------------
3030

31+
## 3.20.0
32+
33+
Released 2026-02-18.
34+
35+
### Added
36+
37+
* Added the `bumpalo::collections::Vec::pop_if` method.
38+
39+
### Fixed
40+
41+
* Fixed a bug in the `bumpalo::collections::String::retain` method in the face
42+
of panics.
43+
* Made `bumpalo::collections::Box<T>` covariant with `T` (just like
44+
`std::boxed::Box<T>`).
45+
46+
--------------------------------------------------------------------------------
47+
3148
## 3.19.1
3249

3350
Released 2025-12-16.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "bumpalo"
1010
readme = "README.md"
1111
repository = "https://github.com/fitzgen/bumpalo"
1212
rust-version = "1.71.1"
13-
version = "3.19.1"
13+
version = "3.20.0"
1414

1515
[package.metadata.docs.rs]
1616
all-features = true

src/boxed.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ impl<'a, T: ?Sized> Box<'a, T> {
234234
/// ```
235235
#[inline]
236236
pub unsafe fn from_raw(raw: *mut T) -> Self {
237-
// Safety - The preconditions of the unsafe from_raw function ensure raw is valid
237+
// Safety: part of this function's unsafe contract is that the raw
238+
// pointer be non-null.
238239
Box(unsafe { NonNull::new_unchecked(raw) }, PhantomData)
239240
}
240241

@@ -551,15 +552,16 @@ impl<'a, T: ?Sized> fmt::Pointer for Box<'a, T> {
551552
}
552553
}
553554

554-
//This function tests that box isn't contravariant.
555+
///This function tests that box isn't contravariant.
556+
///
555557
/// ```compile_fail
556558
/// fn _box_is_not_contravariant<'sub, 'sup :'sub>(
557-
/// a: Box<&'sup u32>,
558-
/// b: Box<&'sub u32>,
559-
/// f: impl Fn(Box<&'sup u32>),
559+
/// a: Box<&'sup u32>,
560+
/// b: Box<&'sub u32>,
561+
/// f: impl Fn(Box<&'sup u32>),
560562
/// ) {
561-
/// f(a);
562-
/// f(b);
563+
/// f(a);
564+
/// f(b);
563565
/// }
564566
/// ```
565567
#[cfg(doctest)]
@@ -569,14 +571,18 @@ impl<'a, T: ?Sized> Deref for Box<'a, T> {
569571
type Target = T;
570572

571573
fn deref(&self) -> &T {
572-
// Safety - The box points to a valid instance of T allocated with a Bumpalo arena.
574+
// Safety: Our pointer always points to a valid instance of `T`
575+
// allocated within a `Bump` and the `&self` borrow ensures that there
576+
// are no active exclusive borrows.
573577
unsafe { self.0.as_ref() }
574578
}
575579
}
576580

577581
impl<'a, T: ?Sized> DerefMut for Box<'a, T> {
578582
fn deref_mut(&mut self) -> &mut T {
579-
// Safety - The box points to a valid instance of T allocated with a Bumpalo arena.
583+
// Safety: Our pointer always points to a valid instance of `T`
584+
// allocated within a `Bump` and the `&mut self` borrow ensures that
585+
// there are no other active borrows.
580586
unsafe { self.0.as_mut() }
581587
}
582588
}

tests/all/boxed.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ fn test_box_basic() {
2323
assert_eq!("world", &*value);
2424
}
2525

26-
// This function tests that Box is covariant.
27-
// If you change the PhantomData<&'a T> in Box to PhantomData<&'a mut T> the test fails the borrow checker.
26+
// This function tests that `Box` is covariant.
2827
fn _box_is_covariant<'sup, 'sub: 'sup>(
2928
a: Box<&'sup u32>,
3029
b: Box<&'sub u32>,

0 commit comments

Comments
 (0)