extending structs

This commit is contained in:
Maddie 2022-11-03 08:47:26 +00:00 committed by GitHub
parent ca0938b523
commit 70678df036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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])