Unnamed repository; edit this file 'description' to name the repository.
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
|
use std::borrow::Cow;
pub trait BlockLogic
{
fn get_size(&self) -> u8;
}
pub struct Block
{
name: Cow<'static, str>,
logic: Box<dyn BlockLogic>,
}
impl Block
{
pub fn new(name: Cow<'static, str>, logic: Box<dyn BlockLogic>) -> Self
{
Self{name, logic}
}
pub fn get_name(&self) -> &str
{
&self.name
}
pub fn get_size(&self) -> u8
{
self.logic.get_size()
}
}
|