diff --git a/src/lib.rs b/src/lib.rs index 3e863e8..7622dde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,3 +4,15 @@ use extism_pdk::*; pub fn greet(name: String) -> FnResult { Ok(format!("Hello, {}!", name)) } + +#[plugin_fn] +pub fn count_vowels(sentence: String) -> FnResult { + let vowels = "aeiouAEIOU"; + let mut vowel_count = 0; + for c in sentence.chars() { + if vowels.contains(c) { + vowel_count += 1; + } + } + Ok(format!("{vowel_count}")) +}