stalin_compression/lib.rs
1/*
2 * MIT License
3 *
4 * Copyright (c) 2024 Leon Cotten
5 *
6 * This software is provided under the MIT Licence.
7 * See LICENSE for more information.
8 */
9
10struct TheState;
11
12impl TheState {
13 fn new() -> TheState {
14 return TheState{};
15 }
16
17 fn execute_char(&self, data: &mut String) {
18 data.pop();
19 }
20}
21
22pub fn compress_string(mut data: String) -> String {
23 // initialize the communist state
24 let the_communist_state: TheState = TheState::new();
25
26 while !data.is_empty() {
27 the_communist_state.execute_char(&mut data);
28 }
29
30 data
31}