src: use core instead of std in some places, aiming for no_std compat

This commit is contained in:
Victoria Fischer 2024-12-01 16:17:51 +01:00
parent 0f73b42818
commit 36aead9762
6 changed files with 15 additions and 15 deletions

View File

@ -1,7 +1,7 @@
use std::fmt::{Debug, Formatter};
use std::ops::{Mul, Sub, Add};
use core::fmt::{Debug, Formatter};
use core::ops::{Mul, Sub, Add};
use num::{One, pow, integer::Roots};
use std::cmp::{min, max};
use core::cmp::{min, max};
pub trait CoordinateOp: PartialOrd + PartialEq + Sub + Clone + Mul + Copy + One + Add + Eq + Debug where
Self: Sub<Output=Self> {
@ -21,7 +21,7 @@ pub struct Coordinates<S: CoordinateSpace> {
}
impl<S: CoordinateSpace> Debug for Coordinates<S> where S::Data: Debug {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("@")
.field(&self.x)
.field(&self.y)

View File

@ -1,5 +1,5 @@
use num::PrimInt;
use std::ops::BitOr;
use core::ops::BitOr;
use rgb::Rgb;

View File

@ -2,8 +2,8 @@ use crate::geometry::*;
use crate::lib8::interpolate::scale8;
use std::cmp::{max, min};
use std::fmt::{Formatter, Debug};
use core::cmp::{max, min};
use core::fmt::{Formatter, Debug};
pub trait CoordinateView<'a>: Debug {
type Space: CoordinateSpace;
@ -216,7 +216,7 @@ pub struct StrideView<'a> {
}
impl<'a> Debug for StrideView<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.debug_struct("StrideView")
.field("range", &self.range)
.field("step", &self.step_size)
@ -247,8 +247,8 @@ impl<'a> StrideView<'a> {
(map.size.width(), map.size.height())
);
let step_size = VirtualCoordinates::new(
u8::MAX / std::cmp::max(1, range.width()),
u8::MAX / std::cmp::max(1, range.height())
u8::MAX / core::cmp::max(1, range.width()),
u8::MAX / core::cmp::max(1, range.height())
//scale8(255, std::cmp::max(1, range.bottom_right.x - range.top_left.x)),
//scale8(255, std::cmp::max(1, range.bottom_right.y - range.top_left.y))
);

View File

@ -6,7 +6,7 @@ use crate::power::brightness_for_mw;
use crate::geometry::*;
use crate::mappings::*;
use std::fmt::Debug;
use core::fmt::Debug;
struct StrideSampler<'a, P: Pixbuf> {
pixbuf: &'a mut P,
@ -26,7 +26,7 @@ impl<'a, P: Pixbuf> PixelView for StrideSampler<'a, P> {
}
impl<P: Pixbuf, T: FastWrite> Debug for StrideOutput<P, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("StrideOutput").finish()
}
}

View File

@ -7,7 +7,7 @@ use crate::power::AsMilliwatts;
use crate::task::Task;
use crate::time::Periodically;
use running_average::RealTimeRunningAverage;
use std::fmt::Debug;
use core::fmt::Debug;
pub trait HardwarePixel: Send + Sync + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}
impl<T> HardwarePixel for T where T: Send + Sync + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}

View File

@ -1,6 +1,6 @@
use std::fmt;
use core::fmt;
pub trait Task: std::fmt::Debug {
pub trait Task: core::fmt::Debug {
fn tick(&mut self) {}
fn start(&mut self) {}
fn stop(&mut self) {}