36 lines
740 B
Rust
36 lines
740 B
Rust
//! # StringQB
|
|
//!
|
|
//! A query builder using mostly strings, with methods following common SQL syntax
|
|
// #![warn(missing_docs)]
|
|
|
|
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
|
|
);
|
|
}
|
|
} |