1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// Sample Rust module for tree-sitter symbol extraction tests.
pub fn public_function(x: i32) -> i32 {
x + 1
}
fn private_function() {
// not exported
}
pub struct MyStruct {
pub field: String,
}
pub enum Color {
Red,
Green,
Blue,
}
pub trait Drawable {
fn draw(&self);
fn area(&self) -> f64;
}
impl MyStruct {
pub fn new(field: String) -> Self {
Self { field }
}
fn helper(&self) -> usize {
self.field.len()
}
}
impl Drawable for MyStruct {
fn draw(&self) {
println!("drawing {}", self.field);
}
fn area(&self) -> f64 {
0.0
}
}