use regex::Regex;
use std::fmt;
pub fn filename_of_module_path_(module_path:&str) -> String {
let re = Regex::new(r"::").unwrap();
format!("{}", re.replace_all(module_path, "."))
}
#[macro_export]
macro_rules! filename_of_module_path {
() => {{
use $crate::util::filename_of_module_path_;
filename_of_module_path_(module_path!())
}}
}
pub fn string_of_rust_raw_str(s:&str) -> String {
let re1 = Regex::new("^r\" ").unwrap();
let re2 = Regex::new("\"$").unwrap();
format!("{}", re2.replace_all(format!("{}", re1.replace_all(s, "")).as_str(), ""))
}
pub fn debug_truncate<X:fmt::Debug>(x: &X) -> String {
let x = format!("{:?}", x);
format!("{:.80}{}", x, if x.len() > 80 { " ..." } else { "`" } )
}
pub fn display_truncate<X:fmt::Display>(x: &X) -> String {
let x = format!("{}", x);
format!("{:.80}{}", x, if x.len() > 80 { " ..." } else { "" } )
}