Created
March 23, 2020 14:47
-
-
Save BetterProgramming/5359b2a8b203361bc2d56024eb075696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ron::ser; | |
pub fn save() -> std::io::Result<()> { | |
let data = Config { | |
token: private::TOKEN, | |
prefix: private::PREFIX, | |
}; | |
let pretty = PrettyConfig::new() | |
.with_depth_limit(2) | |
.with_separate_tuple_members(true) | |
.with_enum_arrays(true); | |
let s = ser::to_string_pretty(&data, pretty) | |
.expect("Serialization failed!"); | |
let mut file = std::fs::File::create("config.ron")?; | |
if let Err(why) = write!(file, "{}", s) { | |
println!("Failed writing to file: {}", why); | |
} else { | |
println!("Write operation succeeded!"); | |
} | |
return Ok(()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment