use core::ops::Deref;
use read_only::embed;
#[embed]
pub struct Labelled {
#[readonly]
pub label: String,
pub mutable: i32,
}
impl Labelled {
pub fn new(label: &str, mutable: i32) -> Self {
Self {
read_only: ReadOnlyLabelled {
label: label.to_string(),
},
mutable,
}
}
}
impl Deref for ReadOnlyLabelled {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.label
}
}
fn main() {
let item = Labelled::new("arcade", 0);
assert_eq!(item.len(), 6);
assert!(item.starts_with("arc"));
assert_eq!(item.mutable, 0);
}