core: convert io::Res over to the Drop trait
This commit is contained in:
parent
e4d4a1499b
commit
e22d2bc4bc
1 changed files with 6 additions and 3 deletions
|
@ -1108,10 +1108,13 @@ pub mod fsync {
|
||||||
// Artifacts that need to fsync on destruction
|
// Artifacts that need to fsync on destruction
|
||||||
pub struct Res<t: Copy> {
|
pub struct Res<t: Copy> {
|
||||||
arg: Arg<t>,
|
arg: Arg<t>,
|
||||||
drop {
|
}
|
||||||
|
|
||||||
|
impl<T: Copy> Res<T>: Drop {
|
||||||
|
fn finalize(&self) {
|
||||||
match self.arg.opt_level {
|
match self.arg.opt_level {
|
||||||
option::None => (),
|
None => (),
|
||||||
option::Some(level) => {
|
Some(level) => {
|
||||||
// fail hard if not succesful
|
// fail hard if not succesful
|
||||||
assert((self.arg.fsync_fn)(self.arg.val, level) != -1);
|
assert((self.arg.fsync_fn)(self.arg.val, level) != -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue