mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-14 06:36:33 +02:00
Remove unnecessary null check in FFI exercise (#2432)
We only assign `self.dir` once and we only assign it if the pointer is non-null. We can therefore simplify the drop implementation a little.
This commit is contained in:
parent
28b5b559b3
commit
1c3e4648e4
@ -123,11 +123,9 @@ impl Drop for DirectoryIterator {
|
||||
fn drop(&mut self) {
|
||||
// Call closedir as needed.
|
||||
// ANCHOR_END: Drop
|
||||
if !self.dir.is_null() {
|
||||
// SAFETY: self.dir is not NULL.
|
||||
if unsafe { ffi::closedir(self.dir) } != 0 {
|
||||
panic!("Could not close {:?}", self.path);
|
||||
}
|
||||
// SAFETY: self.dir is never NULL.
|
||||
if unsafe { ffi::closedir(self.dir) } != 0 {
|
||||
panic!("Could not close {:?}", self.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user