Debian Codegraph @

experimental/rust_cxx/hype-bridge.rs

raw
1 use cxx;
2 #[cxx::bridge(namespace = "hype_train")]
3 mod ffi {
4
5 pub struct HypeOutput {
6 output: String,
7 new_len: usize,
8 }
9
10 extern "Rust" {
11 fn hypeify(input: String, num_exclamations: i32) -> HypeOutput;
12 }
13
14 }
15
16 use crate::ffi::HypeOutput;
17
18 pub fn hypeify(input: String, num_exclamations: i32) -> HypeOutput {
19 let mut res = input.to_uppercase();
20 for _ in 0..num_exclamations {
21 res += "!"
22 }
23 return HypeOutput{
24 new_len: res.len(), output: res,
25 }
26
27 }