Skip to content

Instantly share code, notes, and snippets.

View lights0123's full-sized avatar

Ben Schattinger lights0123

View GitHub Profile
use test::Bencher;
#[derive(Debug)]
pub struct Rate {
pub id: u8,
pub from: String,
pub to: String,
pub exchange: String,
pub rate: f64,
pub vol: f64,
fn escape_str<W: fmt::Write>(mut f: W, mut s: &str, replacements: &[(u8, &str)]) -> fmt::Result {
while !s.is_empty() {
let (idx, replacement) = s
.as_bytes()
.iter()
.enumerate()
.find_map(|(i, c)| {
replacements
.iter()
.find(|(r, _)| c == r)