Skip to content

Commit

Permalink
Revert unnecessary changes
Browse files Browse the repository at this point in the history
The changes might be good, but I want to keep this PR small and
focused. If we end up with the extra `cfg` statements, we should
include a comment to let students know what they do: we’re targeting
people new to Rust, so we need to be careful with explanations.
  • Loading branch information
mgeisler committed Jun 21, 2023
1 parent b5f0977 commit b455abb
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/exercises/day-3/safe-ffi-wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ mod ffi {

use std::ffi::{CStr, CString, OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::ptr::addr_of;

#[derive(Debug)]
struct DirectoryIterator {
Expand Down Expand Up @@ -108,7 +107,7 @@ impl Iterator for DirectoryIterator {
}
// SAFETY: dirent is not NULL and dirent.d_name is NUL
// terminated.
let d_name = unsafe { CStr::from_ptr(addr_of!((*dirent).d_name).cast()) };
let d_name = unsafe { CStr::from_ptr((*dirent).d_name.as_ptr()) };
let os_str = OsStr::from_bytes(d_name.to_bytes());
Some(os_str.to_owned())
}
Expand Down Expand Up @@ -142,7 +141,6 @@ mod tests {
use std::error::Error;

#[test]
#[cfg(not(miri))]
fn test_nonexisting_directory() {
let iter = DirectoryIterator::new("no-such-directory");
assert!(iter.is_err());
Expand All @@ -161,7 +159,6 @@ mod tests {
}

#[test]
#[cfg(not(miri))]
fn test_nonempty_directory() -> Result<(), Box<dyn Error>> {
let tmp = tempfile::TempDir::new()?;
std::fs::write(tmp.path().join("foo.txt"), "The Foo Diaries\n")?;
Expand Down

0 comments on commit b455abb

Please sign in to comment.