mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
core: convert io::Res over to the Drop trait
This commit is contained in:
parent
e4d4a1499b
commit
e22d2bc4bc
@ -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…
Reference in New Issue
Block a user