Skip to content

Commit ee6e835

Browse files
committed
Move DropGuard into wait_until_rng_ready
1 parent 062cc24 commit ee6e835

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/use_file.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ fn get_rng_fd() -> Result<libc::c_int, Error> {
134134
// libsodium uses `libc::poll` similarly to this.
135135
#[cfg(any(target_os = "android", target_os = "linux"))]
136136
fn wait_until_rng_ready() -> Result<(), Error> {
137+
struct DropGuard<F: FnMut()>(F);
138+
139+
impl<F: FnMut()> Drop for DropGuard<F> {
140+
fn drop(&mut self) {
141+
self.0()
142+
}
143+
}
144+
137145
let fd = open_readonly(b"/dev/random\0")?;
138146
let mut pfd = libc::pollfd {
139147
fd,
@@ -158,11 +166,3 @@ fn wait_until_rng_ready() -> Result<(), Error> {
158166
}
159167
}
160168
}
161-
162-
struct DropGuard<F: FnMut()>(F);
163-
164-
impl<F: FnMut()> Drop for DropGuard<F> {
165-
fn drop(&mut self) {
166-
self.0()
167-
}
168-
}

0 commit comments

Comments
 (0)