]> Repositorios git - scryer-prolog.git/commitdiff
clippy
authorNicolas Luck <[email protected]>
Thu, 1 Feb 2024 12:51:37 +0000 (13:51 +0100)
committerNicolas Luck <[email protected]>
Thu, 1 Feb 2024 12:51:37 +0000 (13:51 +0100)
src/heap_print.rs
src/machine/parsed_results.rs
src/machine/streams.rs
src/machine/system_calls.rs

index 515ebef6f4231e9bad08a7e4bc5df8aad4702da8..e788c253e392b70fc514cf046f1ad5c5539ba148 100644 (file)
@@ -1727,7 +1727,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
                        self.print_stream(stream, max_depth);
                    }
                    (ArenaHeaderTag::TcpListener, listener) => {
-                       self.print_tcp_listener(&*listener, max_depth);
+                       self.print_tcp_listener(&listener, max_depth);
                    }
                    (ArenaHeaderTag::Dropped, _value) => {
                        self.print_impromptu_atom(atom!("$dropped_value"));
index 738bc9385e408bf2ce2f7e551f3d023aab149ad5..a34f13d966618116ae08d4fc91fd48248348c93a 100644 (file)
@@ -25,10 +25,10 @@ pub fn prolog_value_to_json_tring(value: Value) -> String {
                 //escape double quotes
                 format!(
                     "\"{}\"",
-                    s.replace("\"", "\\\"")
-                        .replace("\n", "\\n")
-                        .replace("\t", "\\t")
-                        .replace("\r", "\\r")
+                    s.replace('\"', "\\\"")
+                        .replace('\n', "\\n")
+                        .replace('\t', "\\t")
+                        .replace('\r', "\\r")
                 )
             } else {
                 //return valid json string
@@ -39,22 +39,22 @@ pub fn prolog_value_to_json_tring(value: Value) -> String {
             let mut string_result = "[".to_string();
             for (i, v) in l.iter().enumerate() {
                 if i > 0 {
-                    string_result.push_str(",");
+                    string_result.push(',');
                 }
                 string_result.push_str(&prolog_value_to_json_tring(v.clone()));
             }
-            string_result.push_str("]");
+            string_result.push(']');
             string_result
         }
         Value::Structure(s, l) => {
             let mut string_result = format!("\"{}\":[", s.as_str());
             for (i, v) in l.iter().enumerate() {
                 if i > 0 {
-                    string_result.push_str(",");
+                    string_result.push(',');
                 }
                 string_result.push_str(&prolog_value_to_json_tring(v.clone()));
             }
-            string_result.push_str("]");
+            string_result.push(']');
             string_result
         }
         _ => "null".to_string(),
@@ -65,7 +65,7 @@ fn prolog_match_to_json_string(query_match: &QueryMatch) -> String {
     let mut string_result = "{".to_string();
     for (i, (k, v)) in query_match.bindings.iter().enumerate() {
         if i > 0 {
-            string_result.push_str(",");
+            string_result.push(',');
         }
         string_result.push_str(&format!(
             "\"{}\":{}",
@@ -73,7 +73,7 @@ fn prolog_match_to_json_string(query_match: &QueryMatch) -> String {
             prolog_value_to_json_tring(v.clone())
         ));
     }
-    string_result.push_str("}");
+    string_result.push('}');
     string_result
 }
 
@@ -85,7 +85,7 @@ impl ToString for QueryResolution {
             QueryResolution::Matches(matches) => {
                 let matches_json: Vec<String> = matches
                     .iter()
-                    .map(|m| prolog_match_to_json_string(m))
+                    .map(prolog_match_to_json_string)
                     .collect();
                 format!("[{}]", matches_json.join(","))
             }
index 53269bf49a62817ac884cc0713a43dee3aa680db..e05ad9837904104a89296d498ceeb3af7073fe11 100644 (file)
@@ -1875,7 +1875,7 @@ impl MachineState {
             };
 
             if path.extension().is_none() {
-                if let Some(metadata) = file.metadata().ok() {
+                if let Ok(metadata) = file.metadata() {
                     if metadata.is_dir() {
                         path.set_extension("pl");
                         continue;
index 5a10358d8882e75f6e51c8f19e28c94cb918113f..73bf62f226ec4ff5ae2ad9fe14c33c68605d2c51 100644 (file)
@@ -5629,7 +5629,7 @@ impl Machine {
 
     #[inline(always)]
     pub(crate) fn inference_count(&mut self, count_var: HeapCellValue, count: Integer) {
-        if let Some(value) = <&Integer as TryInto<i64>>::try_into(&count).ok() {
+        if let Ok(value) = <&Integer as TryInto<i64>>::try_into(&count) {
             self.machine_st
                 .unify_fixnum(Fixnum::build_with(value), count_var);
         } else {