Skip to content

Instantly share code, notes, and snippets.

@akiradeveloper
Created April 15, 2020 05:58
Show Gist options
  • Save akiradeveloper/dcf523422726efc8ae52a0a466972ef6 to your computer and use it in GitHub Desktop.
Save akiradeveloper/dcf523422726efc8ae52a0a466972ef6 to your computer and use it in GitHub Desktop.
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