use Fun.protect in bracket
This commit is contained in:
parent
3c2e61176a
commit
28af6b3b9e
1 changed files with 1 additions and 3 deletions
|
@ -1,7 +1,5 @@
|
||||||
let bracket ~make:(lazy x) ~act ~free =
|
let bracket ~make:(lazy x) ~act ~free =
|
||||||
match act x with
|
Fun.protect (fun () -> act x) ~finally:(fun () -> free x)
|
||||||
| result -> free x; result
|
|
||||||
| exception e -> free x; raise e
|
|
||||||
|
|
||||||
let infile ~act name =
|
let infile ~act name =
|
||||||
bracket ~make:(lazy (open_in name)) ~act ~free:close_in_noerr
|
bracket ~make:(lazy (open_in name)) ~act ~free:close_in_noerr
|
||||||
|
|
Loading…
Reference in a new issue