Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

No unreleased changes yet
- Added a `?Sized` constraint to `T` in `Mutex<T>`, allowing it to work with unsized types, such as trait objects.

## [v1.1.2] - 2023-08-09

Expand Down Expand Up @@ -69,20 +69,21 @@ If you're seeing a linker error like `undefined symbol: _critical_section_1_0_ac
```

- For single-core Cortex-M targets in privileged mode:

```toml
[dependencies]
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}
```

- For single-hart RISC-V targets in privileged mode:

```toml
[dependencies]
riscv = { version = "0.10", features = ["critical-section-single-hart"]}
```

- For other targets: check if your HAL or architecture-support crate has a `critical-section 1.0` implementation available. Otherwise, [provide your own](https://github.com/rust-embedded/critical-section#providing-an-implementation).


## [v0.2.7] - 2022-04-08

- Add support for AVR targets.
Expand Down
2 changes: 1 addition & 1 deletion src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use core::cell::{Ref, RefCell, RefMut, UnsafeCell};
/// [`std::sync::Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
/// [interior mutability]: https://doc.rust-lang.org/reference/interior-mutability.html
#[derive(Debug)]
pub struct Mutex<T> {
pub struct Mutex<T: ?Sized> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add ?Sized in all the impl blocks too, like impl<T: ?Sized> Mutex<T>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the compiler throws errors because the impl of UnsafeCell<T> doesn't mark T as ?Sized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a way to create a Mutex of an unsized type, defining the struct with T: ?Sized is pointless, isn't it?

→ Can this pull request be closed?

inner: UnsafeCell<T>,
}

Expand Down
Loading