mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 12:56:48 +00:00
Remove transmute
in Vm{Reader,Writer}
This commit is contained in:
parent
2c21b2a3a8
commit
e1e5f9f575
@ -548,10 +548,13 @@ impl<'a> VmReader<'a, Infallible> {
|
|||||||
|
|
||||||
/// Converts to a fallible reader.
|
/// Converts to a fallible reader.
|
||||||
pub fn to_fallible(self) -> VmReader<'a, Fallible> {
|
pub fn to_fallible(self) -> VmReader<'a, Fallible> {
|
||||||
// SAFETY: It is safe to transmute to a fallible reader since
|
// It is safe to construct a fallible reader since an infallible reader covers the
|
||||||
// 1. the fallibility is a zero-sized marker type,
|
// capabilities of a fallible reader.
|
||||||
// 2. an infallible reader covers the capabilities of a fallible reader.
|
VmReader {
|
||||||
unsafe { core::mem::transmute(self) }
|
cursor: self.cursor,
|
||||||
|
end: self.end,
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,10 +802,13 @@ impl<'a> VmWriter<'a, Infallible> {
|
|||||||
|
|
||||||
/// Converts to a fallible writer.
|
/// Converts to a fallible writer.
|
||||||
pub fn to_fallible(self) -> VmWriter<'a, Fallible> {
|
pub fn to_fallible(self) -> VmWriter<'a, Fallible> {
|
||||||
// SAFETY: It is safe to transmute to a fallible writer since
|
// It is safe to construct a fallible reader since an infallible reader covers the
|
||||||
// 1. the fallibility is a zero-sized marker type,
|
// capabilities of a fallible reader.
|
||||||
// 2. an infallible reader covers the capabilities of a fallible reader.
|
VmWriter {
|
||||||
unsafe { core::mem::transmute(self) }
|
cursor: self.cursor,
|
||||||
|
end: self.end,
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user