Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static BSPACE_CHAR: char = '#';
- pub fn stack_based(arg1: &String, arg2: &String) -> bool {
- let process_string = |s: &String| -> String {
- let mut result = String::with_capacity(s.len());
- for c in s.chars() {
- if c != BSPACE_CHAR {
- result.push(c);
- } else {
- result.pop();
- }
- }
- result
- };
- process_string(arg1) == process_string(arg2)
- }
- #[cfg(test)]
- mod tests {
- #[test]
- fn stack_based_test() {
- assert_eq!(
- super::stack_based(&String::from("K#Test##+#"), &String::from("Test##ξ#")),
- true
- );
- assert_eq!(
- super::stack_based(&String::from("##деленe#ити"), &String::from("делениy#ти")),
- true
- );
- }
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement