src: use core instead of std in some places, aiming for no_std compat
This commit is contained in:
parent
0f73b42818
commit
36aead9762
@ -1,7 +1,7 @@
|
|||||||
use std::fmt::{Debug, Formatter};
|
use core::fmt::{Debug, Formatter};
|
||||||
use std::ops::{Mul, Sub, Add};
|
use core::ops::{Mul, Sub, Add};
|
||||||
use num::{One, pow, integer::Roots};
|
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
|
pub trait CoordinateOp: PartialOrd + PartialEq + Sub + Clone + Mul + Copy + One + Add + Eq + Debug where
|
||||||
Self: Sub<Output=Self> {
|
Self: Sub<Output=Self> {
|
||||||
@ -21,7 +21,7 @@ pub struct Coordinates<S: CoordinateSpace> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<S: CoordinateSpace> Debug for Coordinates<S> where S::Data: Debug {
|
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("@")
|
f.debug_tuple("@")
|
||||||
.field(&self.x)
|
.field(&self.x)
|
||||||
.field(&self.y)
|
.field(&self.y)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use num::PrimInt;
|
use num::PrimInt;
|
||||||
use std::ops::BitOr;
|
use core::ops::BitOr;
|
||||||
|
|
||||||
use rgb::Rgb;
|
use rgb::Rgb;
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ use crate::geometry::*;
|
|||||||
|
|
||||||
use crate::lib8::interpolate::scale8;
|
use crate::lib8::interpolate::scale8;
|
||||||
|
|
||||||
use std::cmp::{max, min};
|
use core::cmp::{max, min};
|
||||||
use std::fmt::{Formatter, Debug};
|
use core::fmt::{Formatter, Debug};
|
||||||
|
|
||||||
pub trait CoordinateView<'a>: Debug {
|
pub trait CoordinateView<'a>: Debug {
|
||||||
type Space: CoordinateSpace;
|
type Space: CoordinateSpace;
|
||||||
@ -216,7 +216,7 @@ pub struct StrideView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Debug for 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")
|
f.debug_struct("StrideView")
|
||||||
.field("range", &self.range)
|
.field("range", &self.range)
|
||||||
.field("step", &self.step_size)
|
.field("step", &self.step_size)
|
||||||
@ -247,8 +247,8 @@ impl<'a> StrideView<'a> {
|
|||||||
(map.size.width(), map.size.height())
|
(map.size.width(), map.size.height())
|
||||||
);
|
);
|
||||||
let step_size = VirtualCoordinates::new(
|
let step_size = VirtualCoordinates::new(
|
||||||
u8::MAX / std::cmp::max(1, range.width()),
|
u8::MAX / core::cmp::max(1, range.width()),
|
||||||
u8::MAX / std::cmp::max(1, range.height())
|
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.x - range.top_left.x)),
|
||||||
//scale8(255, std::cmp::max(1, range.bottom_right.y - range.top_left.y))
|
//scale8(255, std::cmp::max(1, range.bottom_right.y - range.top_left.y))
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,7 @@ use crate::power::brightness_for_mw;
|
|||||||
use crate::geometry::*;
|
use crate::geometry::*;
|
||||||
use crate::mappings::*;
|
use crate::mappings::*;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
struct StrideSampler<'a, P: Pixbuf> {
|
struct StrideSampler<'a, P: Pixbuf> {
|
||||||
pixbuf: &'a mut P,
|
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> {
|
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()
|
f.debug_struct("StrideOutput").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use crate::power::AsMilliwatts;
|
|||||||
use crate::task::Task;
|
use crate::task::Task;
|
||||||
use crate::time::Periodically;
|
use crate::time::Periodically;
|
||||||
use running_average::RealTimeRunningAverage;
|
use running_average::RealTimeRunningAverage;
|
||||||
use std::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
pub trait HardwarePixel: Send + Sync + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}
|
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 {}
|
impl<T> HardwarePixel for T where T: Send + Sync + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}
|
||||||
|
@ -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 tick(&mut self) {}
|
||||||
fn start(&mut self) {}
|
fn start(&mut self) {}
|
||||||
fn stop(&mut self) {}
|
fn stop(&mut self) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user