Created
April 15, 2020 05:58
-
-
Save akiradeveloper/dcf523422726efc8ae52a0a466972ef6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait BlockDevice { | |
fn write(&mut self); | |
} | |
type sector_t = u64; | |
struct Local { | |
path: String | |
} | |
impl BlockDevice for Local { | |
fn write(&mut self) {} | |
} | |
struct Linear<B: BlockDevice> { | |
backing: B, | |
offset: sector_t, | |
} | |
impl <B: BlockDevice> BlockDevice for Linear<B> { | |
fn write(&mut self) {} | |
} | |
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn typecheck() { | |
let bdev = Linear { | |
backing: Local { path: "hoge".to_owned() }, | |
offset: 1024, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment