ip/concrete/addr/
range.rs1use core::ops::RangeInclusive;
2
3use super::Address;
4use crate::traits::Afi;
5
6#[derive(Clone, Debug)]
21pub struct Range<A: Afi>(RangeInclusive<Address<A>>);
22
23impl<A: Afi> Range<A> {
24 pub const fn new(start: Address<A>, end: Address<A>) -> Self {
26 Self(start..=end)
27 }
28
29 pub fn contains(&self, addr: &Address<A>) -> bool {
31 self.0.contains(addr)
32 }
33}
34
35impl<A: Afi> From<&RangeInclusive<A::Primitive>> for Range<A> {
36 fn from(range: &RangeInclusive<A::Primitive>) -> Self {
37 Self::new(Address::new(*range.start()), Address::new(*range.end()))
38 }
39}