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
fn main() { | |
let s = "...".to_string(); | |
let a = vec!["abc","abcde","abcdefgh","abcdefghijkl","abcdefghijklmnop"] | |
.into_iter() | |
.map(String::from) | |
.map(|mut string| | |
if string.len() > 5 { string.truncate(5); [string, s.to_string()].join("") } | |
else {string.truncate(5); string}) | |
.collect::<Vec<String>>(); | |
println!("{:?}",a) |
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 console::Style; | |
fn format_float(vec_float: Vec<Option<f64>>){ | |
let bold = Style::new().bold(); | |
let bright_red = Style::new().bright().red(); | |
let bright_black = Style::new().bright().black(); | |
println!("{}", bright_black.apply_to("<dbl>")); | |
for x in vec_float{ | |
match x { | |
Some(i) => if i > 0.0_f64{ |
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 toml::Value; | |
use pad::{PadStr, Alignment}; | |
use std::collections::BTreeMap; | |
use console::style; | |
fn main() { | |
//toml_hash is a `BTreeMap<std::string::String, Vec<Value>>` | |
let toml_hash: BTreeMap<String, Vec<toml::Value>> = toml::from_str(r#" | |
foo = [1,nan,3] | |
bar = ["a","b","c"] | |
baz = [2021-03-29, 2020-03-29, 2020-03-29] |