extending structs
This commit is contained in:
parent
ca0938b523
commit
70678df036
20
src/main.rs
20
src/main.rs
@ -1,20 +1,32 @@
|
||||
struct Buffer {
|
||||
enum Mode {
|
||||
Normal,
|
||||
Insert,
|
||||
Select
|
||||
}
|
||||
|
||||
struct Buffer<'a> {
|
||||
data: Vec<String>,
|
||||
name: &str,
|
||||
name: &'a str,
|
||||
path: &'a str,
|
||||
}
|
||||
|
||||
struct Editor {
|
||||
buffer: Buffer,
|
||||
cursor: [i32, 2],
|
||||
mode: Mode;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let bufffer = Buffer {
|
||||
data: Vec::from([String::from("a test")]),
|
||||
name: "uhh"
|
||||
data: Vec::from([String::from("Hello"), String::from("World")]),
|
||||
name: "[No Name]",
|
||||
path: "/home/spy",
|
||||
};
|
||||
|
||||
let editor = Editor {
|
||||
buffer: bufffer,
|
||||
cursor: [0, 0],
|
||||
mode: Mode::Normal,
|
||||
};
|
||||
|
||||
println!("{}", editor.buffer.data[0])
|
||||
|
Loading…
Reference in New Issue
Block a user