From cf9c904f37957dbc00519542bac46f2df121a449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B8=E6=9D=BE=E6=9E=9C?= Date: Sat, 17 Aug 2024 21:21:31 +0800 Subject: [PATCH] Added a `?Sized` constraint to `T` in `Mutex` --- CHANGELOG.md | 5 +++-- src/mutex.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afd47a3..1d14e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`, allowing it to work with unsized types, such as trait objects. ## [v1.1.2] - 2023-08-09 @@ -69,12 +69,14 @@ 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"]} @@ -82,7 +84,6 @@ If you're seeing a linker error like `undefined symbol: _critical_section_1_0_ac - 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. diff --git a/src/mutex.rs b/src/mutex.rs index c9ea6ff..f2d2f7c 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -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 { +pub struct Mutex { inner: UnsafeCell, }