Просмотр исходного кода

Merge pull request #44 from steveklabnik/master

fail -> panic
Simon Sapin 12 лет назад
Родитель
Сommit
9142b86a81
4 измененных файлов с 14 добавлено и 14 удалено
  1. 1 1
      src/lib.rs
  2. 1 1
      src/parser.rs
  3. 6 6
      src/punycode.rs
  4. 6 6
      src/tests.rs

+ 1 - 1
src/lib.rs

@@ -65,7 +65,7 @@ assert!(issue_list_url.query == Some("labels=E-easy&state=open".to_string()));
 assert!(issue_list_url.fragment == None);
 match issue_list_url.scheme_data {
     RelativeSchemeData(..) => {},  // Expected
-    NonRelativeSchemeData(..) => fail!(),
+    NonRelativeSchemeData(..) => panic!(),
 }
 ```
 

+ 1 - 1
src/parser.rs

@@ -619,7 +619,7 @@ fn parse_query_and_fragment(input: &str, parser: &UrlParser)
             };
             Ok((Some(query), fragment))
         },
-        _ => fail!("Programming error. parse_query_and_fragment() should not \
+        _ => panic!("Programming error. parse_query_and_fragment() should not \
                     have been called with input \"{}\"", input)
     }
 }

+ 6 - 6
src/punycode.rs

@@ -207,7 +207,7 @@ fn value_to_digit(value: u32, output: &mut String) {
     let code_point = match value {
         0 ... 25 => value + 0x61,  // a..z
         26 ... 35 => value - 26 + 0x30,  // 0..9
-        _ => fail!()
+        _ => panic!()
     };
     unsafe { output.as_mut_vec().push(code_point as u8) }
 }
@@ -220,7 +220,7 @@ mod tests {
 
     fn one_test(description: &str, decoded: &str, encoded: &str) {
         match decode(encoded) {
-            None => fail!("Decoding {} failed.", encoded),
+            None => panic!("Decoding {} failed.", encoded),
             Some(result) => {
                 let result = String::from_chars(result.as_slice());
                 assert!(result.as_slice() == decoded,
@@ -230,7 +230,7 @@ mod tests {
         }
 
         match encode_str(decoded) {
-            None => fail!("Encoding {} failed.", decoded),
+            None => panic!("Encoding {} failed.", decoded),
             Some(result) => {
                 assert!(result.as_slice() == encoded,
                         format!("Incorrect encoding of {}:\n   {}\n!= {}\n{}",
@@ -243,7 +243,7 @@ mod tests {
         match map.find(&key.to_string()) {
             Some(&String(ref s)) => s.as_slice(),
             None => "",
-            _ => fail!(),
+            _ => panic!(),
         }
     }
 
@@ -258,10 +258,10 @@ mod tests {
                         get_string(o, "decoded"),
                         get_string(o, "encoded")
                     ),
-                    _ => fail!(),
+                    _ => panic!(),
                 }
             },
-            other => fail!("{}", other)
+            other => panic!("{}", other)
         }
     }
 }

+ 6 - 6
src/tests.rs

@@ -32,12 +32,12 @@ fn url_parsing() {
         } = test;
         let base = match Url::parse(base.as_slice()) {
             Ok(base) => base,
-            Err(message) => fail!("Error parsing base {}: {}", base, message)
+            Err(message) => panic!("Error parsing base {}: {}", base, message)
         };
         let url = UrlParser::new().base_url(&base).parse(input.as_slice());
         if expected_scheme.is_none() {
             if url.is_ok() && !expected_failure {
-                fail!("Expected a parse error for URL {}", input);
+                panic!("Expected a parse error for URL {}", input);
             }
             continue
         }
@@ -47,7 +47,7 @@ fn url_parsing() {
                 if expected_failure {
                     continue
                 } else {
-                    fail!("Error parsing URL {}: {}", input, message)
+                    panic!("Error parsing URL {}: {}", input, message)
                 }
             }
         };
@@ -61,7 +61,7 @@ fn url_parsing() {
                         if expected_failure {
                             continue
                         } else {
-                            fail!("{} != {}", a, b)
+                            panic!("{} != {}", a, b)
                         }
                     }
                 }
@@ -156,7 +156,7 @@ fn parse_test_data(input: &str) -> Vec<Test> {
                 "p" => test.path = Some(value),
                 "q" => test.query = Some(value),
                 "f" => test.fragment = Some(value),
-                _ => fail!("Invalid token")
+                _ => panic!("Invalid token")
             }
         }
         tests.push(test)
@@ -188,7 +188,7 @@ fn unescape(input: &str) -> String {
                             u32::parse_bytes(hex.as_bytes(), 16)
                                 .and_then(char::from_u32).unwrap()
                         }
-                        _ => fail!("Invalid test data input"),
+                        _ => panic!("Invalid test data input"),
                     }
                 } else {
                     c