mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
test: enhance Rust test snippet with trait and struct examples
This commit is contained in:
parent
0faff91c72
commit
10877a99f1
1 changed files with 35 additions and 2 deletions
|
@ -520,8 +520,41 @@ if __name__ == "__main__":
|
|||
),
|
||||
"rust": (
|
||||
"test.rs",
|
||||
'fn main() {\n println!("Hello, World!");\n}\n',
|
||||
"main", # Key symbol to check
|
||||
"""// Define a trait
|
||||
trait Greeting {
|
||||
fn greet(&self) -> String;
|
||||
}
|
||||
|
||||
// Define a struct
|
||||
struct Person {
|
||||
name: String,
|
||||
age: u32,
|
||||
}
|
||||
|
||||
// Implement the trait for Person
|
||||
impl Greeting for Person {
|
||||
fn greet(&self) -> String {
|
||||
format!("Hello, {}! You are {} years old.", self.name, self.age)
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation block for Person
|
||||
impl Person {
|
||||
fn new(name: String, age: u32) -> Self {
|
||||
Person { name, age }
|
||||
}
|
||||
}
|
||||
|
||||
// Constants
|
||||
const DEFAULT_NAME: &str = "World";
|
||||
const MAX_AGE: u32 = 150;
|
||||
|
||||
fn main() {
|
||||
let person = Person::new(DEFAULT_NAME.to_string(), 30);
|
||||
println!("{}", person.greet());
|
||||
}
|
||||
""",
|
||||
"Person", # Key symbol to check
|
||||
),
|
||||
"typescript": (
|
||||
"test.ts",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue