stringqb/src/lib.rs

36 lines
740 B
Rust
Raw Normal View History

2019-04-02 16:35:52 -04:00
//! # StringQB
//!
//! A query builder using mostly strings, with methods following common SQL syntax
2019-04-04 16:39:05 -04:00
// #![warn(missing_docs)]
2019-04-02 16:35:52 -04:00
pub mod drivers;
pub mod query_builder;
pub mod types;
pub fn split_join_map<'a>(
string: &'a str,
split_join_by: &str,
map_fn: impl (FnMut(&'a str) -> String)
) -> String {
string.split(split_join_by)
.into_iter()
.map(map_fn)
.collect::<Vec<String>>()
.join(split_join_by)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_split_join_map() {
let start = "a\t,b ,c\n,d";
let expected = "a,b,c,d";
assert_eq!(
split_join_map(start, ",", |s| s.trim().to_string()),
expected
);
}
}