Skip to main content

interstice_sdk/
lib.rs

1pub mod bindings;
2pub mod macros;
3
4pub use interstice_abi;
5pub use interstice_abi::*;
6pub use interstice_sdk_core::*;
7pub use interstice_sdk_macros::*;
8pub use wee_alloc;
9
10pub use std::str::FromStr;
11
12pub fn to_snake_case(name: &str) -> String {
13    name.trim().to_lowercase().replace("-", "_")
14}
15
16pub fn snake_to_camel_case(name: &str) -> String {
17    let node_type_str =
18        name.chars().nth(0).unwrap().to_uppercase().to_string() + &name[1..name.len()];
19    // Remove "_" and add uppercase to the following character
20    node_type_str
21        .split('_')
22        .map(|s| {
23            let mut chars = s.chars();
24            match chars.next() {
25                None => String::new(),
26                Some(f) => f.to_uppercase().to_string() + chars.as_str(),
27            }
28        })
29        .collect::<String>()
30}