shared/types/
range.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use serde::{Deserialize, Serialize};

use crate::types::point::Point;

/// Defines a rectangular range in a two-dimensional space, represented by minimum and maximum points.
///
/// Attributes:
/// - `min`: A `Point` defining the minimum (bottom-left) corner of the range.
/// - `max`: A `Point` defining the maximum (top-right) corner of the range.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Range {
    pub min: Point,
    pub max: Point,
}

impl Range {
    /// Creates a new `Range` with the specified minimum and maximum points.
    ///
    /// # Arguments
    ///
    /// * `min` - A `Point` defining the minimum (bottom-left) corner of the range.
    /// * `max` - A `Point` defining the maximum (top-right) corner of the range.
    ///
    /// # Returns
    ///
    /// A new `Range` with the specified minimum and maximum points.
    pub fn new(min: Point, max: Point) -> Self {
        Range { min, max }
    }
}