services/graphics-server: 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:31:53 +02:00
parent 0316cd2a3a
commit 136aec042b
No known key found for this signature in database
GPG key ID: 6279AEC20A9524EC
5 changed files with 28 additions and 28 deletions

View file

@ -29,9 +29,9 @@ impl From<usize> for GlyphStyle {
/// Convert style to number for use with register-based message passing sytems
// [by bunnie for Xous]
impl Into<usize> for GlyphStyle {
fn into(self) -> usize {
match self {
impl From<GlyphStyle> for usize {
fn from(g: GlyphStyle) -> usize {
match g {
GlyphStyle::Small => 0,
GlyphStyle::Regular => 1,
GlyphStyle::Bold => 2,

View file

@ -99,9 +99,9 @@ impl From<&Point> for (i16, i16) {
}
}
impl Into<usize> for Point {
fn into(self) -> usize {
(self.x as usize) << 16 | (self.y as usize)
impl From<Point> for usize {
fn from(point: Point) -> usize {
(point.x as usize) << 16 | (point.y as usize)
}
}

View file

@ -248,13 +248,13 @@ impl Rectangle {
}
}
impl Into<ClipRect> for Rectangle {
fn into(self) -> ClipRect {
impl From<Rectangle> 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 _,
)
}
}

View file

@ -16,9 +16,9 @@ impl From<bool> for PixelColor {
}
}
impl Into<bool> for PixelColor {
fn into(self) -> bool {
if self == PixelColor::Dark {
impl From<PixelColor> for bool {
fn from(pc: PixelColor) -> bool {
if pc == PixelColor::Dark {
true
} else {
false
@ -36,9 +36,9 @@ impl From<usize> for PixelColor {
}
}
impl Into<usize> for PixelColor {
fn into(self) -> usize {
if self == PixelColor::Light {
impl From<PixelColor> for usize {
fn from(pc: PixelColor) -> usize {
if pc == PixelColor::Light {
0
} else {
1
@ -103,11 +103,11 @@ impl From<usize> for DrawStyle {
}
}
impl Into<usize> for DrawStyle {
fn into(self) -> usize {
impl From<DrawStyle> 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<usize> 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<usize> for DrawStyle {
} else {
fc = 0;
}
(self.stroke_width as usize) << 16 | sc << 2 | fc
(draw_style.stroke_width as usize) << 16 | sc << 2 | fc
}
}

View file

@ -58,9 +58,9 @@ pub enum TextOp {
Render,
ComputeBounds, // maybe we don't need this
}
impl Into<usize> for TextOp {
fn into(self) -> usize {
match self {
impl From<TextOp> for usize {
fn from(op: TextOp) -> usize {
match op {
TextOp::Nop => 0,
TextOp::Render => 1,
TextOp::ComputeBounds => 2,