소스 검색

Use assert!() to check prefix_len in Ipv4Cidr::new

W Etheredge 9 달 전
부모
커밋
bbc3001a90
1개의 변경된 파일1개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 4
      src/wire/ipv4.rs

+ 1 - 4
src/wire/ipv4.rs

@@ -156,11 +156,8 @@ impl Cidr {
     ///
     /// # Panics
     /// This function panics if the prefix length is larger than 32.
-    #[allow(clippy::no_effect)]
     pub const fn new(address: Address, prefix_len: u8) -> Cidr {
-        // Replace with const panic (or assert) when stabilized
-        // see: https://github.com/rust-lang/rust/issues/51999
-        ["Prefix length should be <= 32"][(prefix_len > 32) as usize];
+        assert!(prefix_len <= 32);
         Cidr {
             address,
             prefix_len,