gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
generate random rust code snippets of 10 to 20 lines of codes
- User
generate random rust code snippets of 10 to 20 lines of codes
- Assistant
fn main() { let mut i = 0; while i < 10 { println!("Value of i: {}", i); i += 1; } }struct Person { name: String, age: i32, } impl Person { fn new(name: &str, age: i32) -> Person { Person { name: name.to_string(), age, } } fn greet(&self) { println!("Hello, my name is {} and I am {} years old.", self.name, self.age); } }fn fibonacci(n: u32) -> u32 { if n == 0 { return 0; } else if n == 1 { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } fn main() { let n = 10; println!("Fibonacci number at position {} is: {}", n, fibonacci(n)); }