Got it working
Rust Build / Check (pull_request) Successful in 40s
Rust Build / Rustfmt (pull_request) Failing after 32s
Rust Build / Test Suite (pull_request) Successful in 47s
Rust Build / Clippy (pull_request) Failing after 30s
Rust Build / build (pull_request) Successful in 27s
Rust Build / Check (pull_request) Successful in 40s
Rust Build / Rustfmt (pull_request) Failing after 32s
Rust Build / Test Suite (pull_request) Successful in 47s
Rust Build / Clippy (pull_request) Failing after 30s
Rust Build / build (pull_request) Successful in 27s
This commit is contained in:
+35
-21
@@ -1,4 +1,4 @@
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::io::{BufRead};
|
||||
|
||||
pub const LETTERS: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
@@ -41,6 +41,40 @@ impl NumberParser {
|
||||
}
|
||||
|
||||
pub fn save_file(&self, numbers: Vec<textsender_models::contact::Contact>) {
|
||||
|
||||
// filename := "numbers.json"
|
||||
let filename = String::from("numbers.json");
|
||||
|
||||
match serde_json::to_string(&numbers) {
|
||||
Ok(json_string) => {
|
||||
match std::fs::write(&filename, json_string) {
|
||||
Ok(_) => {
|
||||
println!("Saved to: {filename:?}");
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
};
|
||||
|
||||
// Create json and save it to the filesystem
|
||||
/*
|
||||
jsonData, err := json.MarshalIndent(&vals, "", " ")
|
||||
if err != nil {
|
||||
log.Println("Error marshaling JSON:", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = os.WriteFile(filename, jsonData, 0644)
|
||||
if err != nil {
|
||||
log.Println("Error writing file:", err)
|
||||
return
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn print_values(&self, numbers: &Vec<textsender_models::contact::Contact>) {
|
||||
@@ -150,23 +184,3 @@ impl NumberParser {
|
||||
parsed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
func (prsr NumberParser) SaveFile(vals []contact.Contact) {
|
||||
filename := "numbers.json"
|
||||
|
||||
// Create json and save it to the filesystem
|
||||
jsonData, err := json.MarshalIndent(&vals, "", " ")
|
||||
if err != nil {
|
||||
log.Println("Error marshaling JSON:", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = os.WriteFile(filename, jsonData, 0644)
|
||||
if err != nil {
|
||||
log.Println("Error writing file:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user