Commit 42f44fd4 authored by Clara Engler's avatar Clara Engler
Browse files

tor-netdoc: Make some policy methods const

This commit makes some policy related constructor functions constant, so
we can use them in const expressions, which will be required for the
next commit.
parent 86ec7588
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -81,13 +81,13 @@ pub struct PortRange {
impl PortRange {
    /// Create a new port range spanning from lo to hi, asserting that
    /// the correct invariants hold.
    fn new_unchecked(lo: u16, hi: u16) -> Self {
    const fn new_unchecked(lo: u16, hi: u16) -> Self {
        assert!(lo != 0);
        assert!(lo <= hi);
        PortRange { lo, hi }
    }
    /// Create a port range containing all ports.
    pub fn new_all() -> Self {
    pub const fn new_all() -> Self {
        PortRange::new_unchecked(1, 65535)
    }
    /// Create a new PortRange.
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ pub struct AddrPortPattern {

impl AddrPortPattern {
    /// Return an AddrPortPattern matching all targets.
    pub fn new_all() -> Self {
    pub const fn new_all() -> Self {
        Self {
            pattern: IpPattern::Star,
            ports: PortRange::new_all(),