Selaa lähdekoodia

Use debug_assert!(…)

David Peter 2 vuotta sitten
vanhempi
sitoutus
8dea7501ef
3 muutettua tiedostoa jossa 5 lisäystä ja 5 poistoa
  1. 1 1
      numbat/src/typechecker.rs
  2. 3 3
      numbat/src/unit.rs
  3. 1 1
      numbat/src/vm.rs

+ 1 - 1
numbat/src/typechecker.rs

@@ -315,7 +315,7 @@ impl TypeChecker {
                 if *is_variadic {
                     // For a variadic function, we simply duplicate the parameter type
                     // N times, where N is the number of arguments given.
-                    assert!(parameter_types.len() == 1);
+                    debug_assert!(parameter_types.len() == 1);
 
                     for _ in 1..argument_types.len() {
                         parameter_types.push(parameter_types[0].clone());

+ 3 - 3
numbat/src/unit.rs

@@ -169,7 +169,7 @@ impl Unit {
         factor: ConversionFactor,
         base_unit: Unit,
     ) -> Self {
-        assert!(base_unit.iter().all(|f| f.unit_id.is_base()));
+        debug_assert!(base_unit.iter().all(|f| f.unit_id.is_base()));
 
         Unit::from_factor(UnitFactor {
             prefix: Prefix::none(),
@@ -184,8 +184,8 @@ impl Unit {
 
     pub fn with_prefix(self, prefix: Prefix) -> Self {
         let mut factors: Vec<_> = self.into_iter().collect();
-        assert!(!factors.is_empty());
-        assert!(factors[0].prefix == Prefix::none());
+        debug_assert!(!factors.is_empty());
+        debug_assert!(factors[0].prefix == Prefix::none());
         factors[0].prefix = prefix;
         Self::from_factors(factors)
     }

+ 1 - 1
numbat/src/vm.rs

@@ -495,7 +495,7 @@ impl Vm {
                     let num_args = self.read_u16() as usize;
                     let foreign_function = &self.ffi_callables[function_idx];
 
-                    assert!(foreign_function.arity.contains(&num_args));
+                    debug_assert!(foreign_function.arity.contains(&num_args));
 
                     let mut args = vec![];
                     for _ in 0..num_args {