mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
rust: debugfs: Implement Reader for Mutex<T> only when T is Unpin
Since we are going to make `Mutex<T>` structurally pin the data (i.e. `T`), therefore `.lock()` function only returns a `Guard` that can dereference a mutable reference to `T` if only `T` is `Unpin`, therefore restrict the impl `Reader` block of `Mutex<T>` to that. Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20251022034237.70431-1-boqun.feng@gmail.com
This commit is contained in:
committed by
Peter Zijlstra
parent
795aab353d
commit
37d0472c8a
@@ -50,7 +50,7 @@ pub trait Reader {
|
||||
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result;
|
||||
}
|
||||
|
||||
impl<T: FromStr> Reader for Mutex<T> {
|
||||
impl<T: FromStr + Unpin> Reader for Mutex<T> {
|
||||
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result {
|
||||
let mut buf = [0u8; 128];
|
||||
if reader.len() > buf.len() {
|
||||
|
||||
Reference in New Issue
Block a user