xref: /aosp_15_r20/external/skia/experimental/rust_cxx/hype-bridge.rs (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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" {
hypeify(input: String, num_exclamations: i32) -> HypeOutput11         fn hypeify(input: String, num_exclamations: i32) -> HypeOutput;
12     }
13 
14 }
15 
16 use crate::ffi::HypeOutput;
17 
hypeify(input: String, num_exclamations: i32) -> HypeOutput18 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 }