From 6163414dd12c081d035fb78b709bd0a32fc3bd6c Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:24:55 +0200 Subject: [PATCH 1/9] keyboard: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/keyboard/src/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/keyboard/src/api.rs b/services/keyboard/src/api.rs index 5e1b65c6f..dc771cbbf 100644 --- a/services/keyboard/src/api.rs +++ b/services/keyboard/src/api.rs @@ -35,9 +35,9 @@ impl From for KeyMap { } } } -impl Into for KeyMap { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(map: KeyMap) -> usize { + match map { // note: these indicese correspond to the position on the keyboard menu KeyMap::Qwerty => 0, KeyMap::Azerty => 1, From 01bc25c55db5b663fd7c1bab34facb0592c9920d Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:29:51 +0200 Subject: [PATCH 2/9] apps/vault: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- apps/vault/src/ctap/ctap1.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/vault/src/ctap/ctap1.rs b/apps/vault/src/ctap/ctap1.rs index f81d3b8a2..40b5fafad 100644 --- a/apps/vault/src/ctap/ctap1.rs +++ b/apps/vault/src/ctap/ctap1.rs @@ -18,7 +18,6 @@ use super::status_code::Ctap2StatusCode; use super::CtapState; use std::vec::Vec; use arrayref::array_ref; -use core::convert::Into; use core::convert::TryFrom; use ctap_crypto::rng256::Rng256; use crate::shims::ClockValue; @@ -51,9 +50,9 @@ impl TryFrom for Ctap1Flags { } } -impl Into for Ctap1Flags { - fn into(self) -> u8 { - self as u8 +impl From for u8 { + fn from(flags: Ctap1Flags) -> u8 { + flags as u8 } } From d651ce51ccc395b7171d4a083cdbf714e9937503 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:30:26 +0200 Subject: [PATCH 3/9] services/com: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/com/src/api.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/com/src/api.rs b/services/com/src/api.rs index 8b128ad19..0a5c891fb 100644 --- a/services/com/src/api.rs +++ b/services/com/src/api.rs @@ -36,12 +36,12 @@ impl From<[usize; 2]> for BattStats { } } -impl Into<[usize; 2]> for BattStats { - fn into(self) -> [usize; 2] { +impl From for [usize; 2]{ + fn from(stats: BattStats) -> [usize; 2] { [ - (self.voltage as usize & 0xffff) | ((self.soc as usize) << 16) & 0xFF_0000, - (self.remaining_capacity as usize & 0xffff) - | ((self.current as usize) << 16) & 0xffff_0000, + (stats.voltage as usize & 0xffff) | ((stats.soc as usize) << 16) & 0xFF_0000, + (stats.remaining_capacity as usize & 0xffff) + | ((stats.current as usize) << 16) & 0xffff_0000, ] } } From 0316cd2a3af15e408bf1975b0d4bcf3c85759396 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:30:50 +0200 Subject: [PATCH 4/9] services/content-plugin-api: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/content-plugin-api/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/content-plugin-api/src/lib.rs b/services/content-plugin-api/src/lib.rs index 49576cc0c..0b187e4ce 100644 --- a/services/content-plugin-api/src/lib.rs +++ b/services/content-plugin-api/src/lib.rs @@ -21,9 +21,9 @@ impl core::convert::TryFrom<&Message> for Opcode { } } -impl Into for Opcode { - fn into(self) -> Message { - match self { +impl From for Message { + fn from(opcode: Opcode) -> Message { + match opcode { Opcode::Redraw => Message::Scalar(ScalarMessage { id: 0, arg1: 0, @@ -31,7 +31,7 @@ impl Into for Opcode { arg3: 0, arg4: 0, }), - // _ => panic!("SHCH api: Opcode type not handled by Into(), refer to helper method"), + // _ => panic!("SHCH api: Opcode type not handled by From, refer to helper method"), } } } From 136aec042b1a13b637243d18fec44d6027099859 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:31:53 +0200 Subject: [PATCH 5/9] services/graphics-server: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- .../graphics-server/src/api/glyphstyle.rs | 6 ++--- services/graphics-server/src/api/points.rs | 6 ++--- services/graphics-server/src/api/shapes.rs | 12 ++++----- services/graphics-server/src/api/styles.rs | 26 +++++++++---------- services/graphics-server/src/api/text.rs | 6 ++--- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/services/graphics-server/src/api/glyphstyle.rs b/services/graphics-server/src/api/glyphstyle.rs index c5c08b3c6..7c8679c0c 100644 --- a/services/graphics-server/src/api/glyphstyle.rs +++ b/services/graphics-server/src/api/glyphstyle.rs @@ -29,9 +29,9 @@ impl From for GlyphStyle { /// Convert style to number for use with register-based message passing sytems // [by bunnie for Xous] -impl Into for GlyphStyle { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(g: GlyphStyle) -> usize { + match g { GlyphStyle::Small => 0, GlyphStyle::Regular => 1, GlyphStyle::Bold => 2, diff --git a/services/graphics-server/src/api/points.rs b/services/graphics-server/src/api/points.rs index c0a9fa29a..792ca1ad2 100644 --- a/services/graphics-server/src/api/points.rs +++ b/services/graphics-server/src/api/points.rs @@ -99,9 +99,9 @@ impl From<&Point> for (i16, i16) { } } -impl Into for Point { - fn into(self) -> usize { - (self.x as usize) << 16 | (self.y as usize) +impl From for usize { + fn from(point: Point) -> usize { + (point.x as usize) << 16 | (point.y as usize) } } diff --git a/services/graphics-server/src/api/shapes.rs b/services/graphics-server/src/api/shapes.rs index 8e2088499..718e54582 100644 --- a/services/graphics-server/src/api/shapes.rs +++ b/services/graphics-server/src/api/shapes.rs @@ -248,13 +248,13 @@ impl Rectangle { } } -impl Into for Rectangle { - fn into(self) -> ClipRect { +impl From for ClipRect { + fn from(rectangle: Rectangle) -> ClipRect { ClipRect::new( - self.x0() as _, - self.y0() as _, - self.x1() as _, - self.y1() as _, + rectangle.x0() as _, + rectangle.y0() as _, + rectangle.x1() as _, + rectangle.y1() as _, ) } } diff --git a/services/graphics-server/src/api/styles.rs b/services/graphics-server/src/api/styles.rs index ffeeaeb4d..efdfe5f85 100644 --- a/services/graphics-server/src/api/styles.rs +++ b/services/graphics-server/src/api/styles.rs @@ -16,9 +16,9 @@ impl From for PixelColor { } } -impl Into for PixelColor { - fn into(self) -> bool { - if self == PixelColor::Dark { +impl From for bool { + fn from(pc: PixelColor) -> bool { + if pc == PixelColor::Dark { true } else { false @@ -36,9 +36,9 @@ impl From for PixelColor { } } -impl Into for PixelColor { - fn into(self) -> usize { - if self == PixelColor::Light { +impl From for usize { + fn from(pc: PixelColor) -> usize { + if pc == PixelColor::Light { 0 } else { 1 @@ -103,11 +103,11 @@ impl From for DrawStyle { } } -impl Into for DrawStyle { - fn into(self) -> usize { +impl From for usize { + fn from(draw_style: DrawStyle) -> usize { let sc: usize; - if self.stroke_color.is_some() { - if self.stroke_color.unwrap() == PixelColor::Dark { + if draw_style.stroke_color.is_some() { + if draw_style.stroke_color.unwrap() == PixelColor::Dark { sc = 0b11; } else { sc = 0b10; @@ -116,8 +116,8 @@ impl Into for DrawStyle { sc = 0; } let fc: usize; - if self.fill_color.is_some() { - if self.fill_color.unwrap() == PixelColor::Dark { + if draw_style.fill_color.is_some() { + if draw_style.fill_color.unwrap() == PixelColor::Dark { fc = 0b11; } else { fc = 0b10; @@ -126,7 +126,7 @@ impl Into for DrawStyle { } else { fc = 0; } - (self.stroke_width as usize) << 16 | sc << 2 | fc + (draw_style.stroke_width as usize) << 16 | sc << 2 | fc } } diff --git a/services/graphics-server/src/api/text.rs b/services/graphics-server/src/api/text.rs index 54beb1f58..0a10c2f19 100644 --- a/services/graphics-server/src/api/text.rs +++ b/services/graphics-server/src/api/text.rs @@ -58,9 +58,9 @@ pub enum TextOp { Render, ComputeBounds, // maybe we don't need this } -impl Into for TextOp { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(op: TextOp) -> usize { + match op { TextOp::Nop => 0, TextOp::Render => 1, TextOp::ComputeBounds => 2, From 91e4b9fa1599d72a0c134189b498cfdbf2b0240a Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:32:39 +0200 Subject: [PATCH 6/9] services/ime-plugin-api: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/ime-plugin-api/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/ime-plugin-api/src/lib.rs b/services/ime-plugin-api/src/lib.rs index 9c63a1a43..557f1b908 100644 --- a/services/ime-plugin-api/src/lib.rs +++ b/services/ime-plugin-api/src/lib.rs @@ -34,16 +34,16 @@ pub struct PredictionTriggers { /// trigger word predictions on whitespace pub whitespace: bool, } -impl Into for PredictionTriggers { - fn into(self) -> usize { +impl From for usize { + fn from(pt: PredictionTriggers) -> usize { let mut ret: usize = 0; - if self.newline { + if pt.newline { ret |= 0x1; } - if self.punctuation { + if pt.punctuation { ret |= 0x2; } - if self.whitespace { + if pt.whitespace { ret |= 0x4; } ret From 479694869ac32b4a248b93c868aa7ec2c078cb5e Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:33:18 +0200 Subject: [PATCH 7/9] services/llio: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/llio/src/api.rs | 12 ++++++------ services/llio/src/api/llio_api.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/llio/src/api.rs b/services/llio/src/api.rs index 34e2642dd..1de2d013d 100644 --- a/services/llio/src/api.rs +++ b/services/llio/src/api.rs @@ -27,9 +27,9 @@ impl From for UartType { } } } -impl Into for UartType { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(uart_type: UartType) -> usize { + match uart_type { UartType::Kernel => 0, UartType::Log => 1, UartType::Application => 2, @@ -38,9 +38,9 @@ impl Into for UartType { } } // for the actual bitmask going to hardware -impl Into for UartType { - fn into(self) -> u32 { - match self { +impl From for u32 { + fn from(uart_type: UartType) -> u32 { + match uart_type { UartType::Kernel => 0, UartType::Log => 1, UartType::Application => 2, diff --git a/services/llio/src/api/llio_api.rs b/services/llio/src/api/llio_api.rs index b5b8d2a72..e35de21b8 100644 --- a/services/llio/src/api/llio_api.rs +++ b/services/llio/src/api/llio_api.rs @@ -15,9 +15,9 @@ impl From for VibePattern { } } } -impl Into for VibePattern { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(pat: VibePattern) -> usize { + match pat { VibePattern::Long => 0, VibePattern::Double => 1, VibePattern::Short => 0xffff_ffff, @@ -39,9 +39,9 @@ impl From for ClockMode { } } } -impl Into for ClockMode { - fn into(self) -> usize { - match self { +impl From for usize { + fn from(mode: ClockMode) -> usize { + match mode { ClockMode::Low => 0, ClockMode::AllOn => 0xffff_ffff, } From 59e3378d11605926a3abbba2e16110af0e1d8cf0 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:33:46 +0200 Subject: [PATCH 8/9] services/root-keys: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- services/root-keys/src/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/root-keys/src/api.rs b/services/root-keys/src/api.rs index 0e56514b4..2d723fa96 100644 --- a/services/root-keys/src/api.rs +++ b/services/root-keys/src/api.rs @@ -315,9 +315,9 @@ impl From:: for BackupKeyboardLayout { } } } -impl Into:: for BackupKeyboardLayout { - fn into(self) -> KeyMap { - match self { +impl From for KeyMap { + fn from(layout: BackupKeyboardLayout) -> KeyMap { + match layout { BackupKeyboardLayout::Qwerty => KeyMap::Qwerty, BackupKeyboardLayout::Braille => KeyMap::Braille, BackupKeyboardLayout::Dvorak => KeyMap::Dvorak, From c74d54f345807b10111ea704043127af558f5d74 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 15:35:45 +0200 Subject: [PATCH 9/9] xous-rs: Implement From instead of Into Signed-off-by: Jean-Pierre De Jesus DIAZ --- xous-rs/src/arch/hosted/process.rs | 18 +++++++++--------- xous-rs/src/arch/riscv/process.rs | 4 ++-- xous-rs/src/arch/test/mod.rs | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/xous-rs/src/arch/hosted/process.rs b/xous-rs/src/arch/hosted/process.rs index 66cd3e5a5..04a1e9f9c 100644 --- a/xous-rs/src/arch/hosted/process.rs +++ b/xous-rs/src/arch/hosted/process.rs @@ -53,13 +53,13 @@ impl ProcessArgs { } } -impl Into<[usize; 7]> for &ProcessInit { - fn into(self) -> [usize; 7] { +impl From<&ProcessInit> for [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[4..8].try_into().unwrap()) as _, - u32::from_le_bytes(self.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[0..4].try_into().unwrap()) as _, + u32::from_le_bytes(init.key.0[4..8].try_into().unwrap()) as _, + u32::from_le_bytes(init.key.0[8..12].try_into().unwrap()) as _, + u32::from_le_bytes(init.key.0[12..16].try_into().unwrap()) as _, 0, 0, 0, @@ -120,9 +120,9 @@ impl From<[usize; 8]> for ProcessStartup { } } -impl Into<[usize; 7]> for &ProcessStartup { - fn into(self) -> [usize; 7] { - [self.pid.get() as _, 0, 0, 0, 0, 0, 0] +impl From<&ProcessStartup> for [usize; 7] { + fn from(startup: &ProcessStartup) -> [usize; 7] { + [startup.pid.get() as _, 0, 0, 0, 0, 0, 0] } } diff --git a/xous-rs/src/arch/riscv/process.rs b/xous-rs/src/arch/riscv/process.rs index 9e9b6aae8..0d8769e00 100644 --- a/xous-rs/src/arch/riscv/process.rs +++ b/xous-rs/src/arch/riscv/process.rs @@ -52,7 +52,7 @@ pub struct ProcessInit { // 6 } -impl Into<[usize; 7]> for &ProcessInit { +impl From<&ProcessInit> for [usize; 7] { fn into(self) -> [usize; 7] { [ 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] { [self.pid.get() as _, self.connection as _, 0, 0, 0, 0, 0] } diff --git a/xous-rs/src/arch/test/mod.rs b/xous-rs/src/arch/test/mod.rs index 4450eddab..ec13bb75e 100644 --- a/xous-rs/src/arch/test/mod.rs +++ b/xous-rs/src/arch/test/mod.rs @@ -20,13 +20,13 @@ impl ProcessKey { } } -impl Into for ProcessKey { - fn into(self) -> String { - let mut out = String::new(); +impl core::fmt::Display for ProcessKey { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 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 { - fn into(self) -> [usize; 7] { - [self.pid.get() as _, 0, 0, 0, 0, 0, 0] +impl From<&ProcessStartup> for [usize; 7] { + fn from(startup: &ProcessStartup) -> [usize; 7] { + [startup.pid.get() as _, 0, 0, 0, 0, 0, 0] } } -impl Into<[usize; 7]> for &ProcessInit { - fn into(self) -> [usize; 7] { +impl From<&ProcessInit> for [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[4..8].try_into().unwrap()) as _,