xous-rs: Implement From instead of Into

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
This commit is contained in:
Jean-Pierre De Jesus DIAZ 2022-10-12 15:35:45 +02:00
parent 59e3378d11
commit c74d54f345
No known key found for this signature in database
GPG key ID: 6279AEC20A9524EC
3 changed files with 21 additions and 21 deletions

View file

@ -53,13 +53,13 @@ impl ProcessArgs {
} }
} }
impl Into<[usize; 7]> for &ProcessInit { impl From<&ProcessInit> for [usize; 7] {
fn into(self) -> [usize; 7] { fn from(init: &ProcessInit) -> [usize; 7] {
[ [
u32::from_le_bytes(self.key.0[0..4].try_into().unwrap()) as _, u32::from_le_bytes(init.key.0[0..4].try_into().unwrap()) as _,
u32::from_le_bytes(self.key.0[4..8].try_into().unwrap()) as _, u32::from_le_bytes(init.key.0[4..8].try_into().unwrap()) as _,
u32::from_le_bytes(self.key.0[8..12].try_into().unwrap()) as _, u32::from_le_bytes(init.key.0[8..12].try_into().unwrap()) as _,
u32::from_le_bytes(self.key.0[12..16].try_into().unwrap()) as _, u32::from_le_bytes(init.key.0[12..16].try_into().unwrap()) as _,
0, 0,
0, 0,
0, 0,
@ -120,9 +120,9 @@ impl From<[usize; 8]> for ProcessStartup {
} }
} }
impl Into<[usize; 7]> for &ProcessStartup { impl From<&ProcessStartup> for [usize; 7] {
fn into(self) -> [usize; 7] { fn from(startup: &ProcessStartup) -> [usize; 7] {
[self.pid.get() as _, 0, 0, 0, 0, 0, 0] [startup.pid.get() as _, 0, 0, 0, 0, 0, 0]
} }
} }

View file

@ -52,7 +52,7 @@ pub struct ProcessInit {
// 6 // 6
} }
impl Into<[usize; 7]> for &ProcessInit { impl From<&ProcessInit> for [usize; 7] {
fn into(self) -> [usize; 7] { fn into(self) -> [usize; 7] {
[ [
self.stack.addr.get(), self.stack.addr.get(),
@ -121,7 +121,7 @@ impl From<[usize; 8]> for ProcessStartup {
} }
} }
impl Into<[usize; 7]> for &ProcessStartup { impl From<&ProcessStartup> for [usize; 7] {
fn into(self) -> [usize; 7] { fn into(self) -> [usize; 7] {
[self.pid.get() as _, self.connection as _, 0, 0, 0, 0, 0] [self.pid.get() as _, self.connection as _, 0, 0, 0, 0, 0]
} }

View file

@ -20,13 +20,13 @@ impl ProcessKey {
} }
} }
impl Into<String> for ProcessKey { impl core::fmt::Display for ProcessKey {
fn into(self) -> String { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut out = String::new();
for i in self.0 { for i in self.0 {
out.push_str(&format!("{:02x}", i)); write!(f, "{:02x}", i)?;
} }
out
Ok(())
} }
} }
@ -184,14 +184,14 @@ impl From<[usize; 8]> for ProcessStartup {
} }
} }
impl Into<[usize; 7]> for &ProcessStartup { impl From<&ProcessStartup> for [usize; 7] {
fn into(self) -> [usize; 7] { fn from(startup: &ProcessStartup) -> [usize; 7] {
[self.pid.get() as _, 0, 0, 0, 0, 0, 0] [startup.pid.get() as _, 0, 0, 0, 0, 0, 0]
} }
} }
impl Into<[usize; 7]> for &ProcessInit { impl From<&ProcessInit> for [usize; 7] {
fn into(self) -> [usize; 7] { fn from(init: &ProcessInit) -> [usize; 7] {
[ [
u32::from_le_bytes(self.key.0[0..4].try_into().unwrap()) as _, u32::from_le_bytes(self.key.0[0..4].try_into().unwrap()) as _,
u32::from_le_bytes(self.key.0[4..8].try_into().unwrap()) as _, u32::from_le_bytes(self.key.0[4..8].try_into().unwrap()) as _,