Crates.io | text_converter |
lib.rs | text_converter |
version | 0.1.0 |
source | src |
created_at | 2023-02-13 12:14:19.985312 |
updated_at | 2023-02-13 12:14:19.985312 |
description | A trait that helps with manipulating text |
homepage | |
repository | https://github.com/fruit-bird/text_converter |
max_upload_size | |
id | 783905 |
size | 4,838 |
A trait with all methods needed to convert text into a specific format
use text_converter::TextConverter;
struct ReverseText;
impl TextConverter for ReverseText {
fn converter(input: impl AsRef<str>) -> String {
input.as_ref().chars().rev().collect()
}
}
let clipboard_reverse = ReverseText::new_from_clipboard();
let file_reverse = ReverseText::new_from_file("input.txt");
let reverse_text = ReverseText::new_from_text("Hello World!");
assert_eq!("!dlroW olleH", reverse_text);