mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
switch to using Point in one-d-derive macros
Also start updates to make point more generic, still not complete or fully implemented. Some code cleanup
This commit is contained in:
@@ -15,9 +15,37 @@ use crate::ResultPoint;
|
||||
*/
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct Point {
|
||||
pub(crate) x: f32,
|
||||
pub(crate) y: f32,
|
||||
pub struct PointT<T> {
|
||||
pub x: T,
|
||||
pub y: T,
|
||||
}
|
||||
// #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
// #[derive(Debug, Clone, Copy, Default)]
|
||||
// pub struct Point {
|
||||
// pub(crate) x: f32,
|
||||
// pub(crate) y: f32,
|
||||
// }
|
||||
|
||||
pub type PointF = PointT<f32>;
|
||||
pub type PointI = PointT<u32>;
|
||||
pub type Point = PointF;
|
||||
|
||||
impl Into<PointI> for Point {
|
||||
fn into(self) -> PointI {
|
||||
PointI{
|
||||
x: self.x.floor() as u32,
|
||||
y: self.y.floor() as u32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Point> for PointI {
|
||||
fn into(self) -> Point {
|
||||
Point {
|
||||
x: self.x as f32,
|
||||
y: self.y as f32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** An alias for `Point::new`. */
|
||||
@@ -33,9 +61,6 @@ pub fn point_i<T: Into<i64>>(x: T, y: T) -> Point {
|
||||
Point::new(x.into() as f32, y.into() as f32)
|
||||
}
|
||||
|
||||
/** Currently necessary because the external OneDReader proc macro uses it. */
|
||||
pub type RXingResultPoint = Point;
|
||||
|
||||
impl Hash for Point {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.x.to_string().hash(state);
|
||||
|
||||
Reference in New Issue
Block a user