how can I write a function in Rust that reverses a string?
- User
how can I write a function in Rust that reverses a string?
Assistant
fn reverse_string(s: &str) -> String { let mut reversed = String::new(); for c in s.chars().rev() { reversed.push(c); } reversed }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.