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>,
|
data: Vec<String>,
|
||||||
name: &str,
|
name: &'a str,
|
||||||
|
path: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Editor {
|
struct Editor {
|
||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
|
cursor: [i32, 2],
|
||||||
|
mode: Mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let bufffer = Buffer {
|
let bufffer = Buffer {
|
||||||
data: Vec::from([String::from("a test")]),
|
data: Vec::from([String::from("Hello"), String::from("World")]),
|
||||||
name: "uhh"
|
name: "[No Name]",
|
||||||
|
path: "/home/spy",
|
||||||
};
|
};
|
||||||
|
|
||||||
let editor = Editor {
|
let editor = Editor {
|
||||||
buffer: bufffer,
|
buffer: bufffer,
|
||||||
|
cursor: [0, 0],
|
||||||
|
mode: Mode::Normal,
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{}", editor.buffer.data[0])
|
println!("{}", editor.buffer.data[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user