Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Remove unnecessary usages of `.unwrap()`.
Remaining usages are simmilar to '.expect()' were invariants should
make it impossible for it to fail. Due to a lack of understanding
we leave don't try to turn them into `expect()` just yet.
  • Loading branch information
Byron committed Dec 15, 2022
1 parent 7e300c6 commit a94d14b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/dir_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<C: ClientState> DirEntry<C> {
let dir_entry = DirEntry::from_path(self.depth, &path, true, origins)?;

if dir_entry.file_type.is_dir() {
let target = fs::read_link(&path).unwrap();
let target = fs::read_link(&path).map_err(|err| Error::from_io(self.depth, err))?;
for ancestor in self.follow_link_ancestors.iter().rev() {
if target.as_path() == ancestor.as_ref() {
return Err(Error::from_loop(
Expand Down
6 changes: 1 addition & 5 deletions src/core/dir_entry_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ impl<C: ClientState> Iterator for DirEntryIter<C> {
type Item = Result<DirEntry<C>>;
fn next(&mut self) -> Option<Self::Item> {
loop {
if self.read_dir_results_stack.is_empty() {
return None;
}

// 1. Get current read dir results iter from top of stack
let top_read_dir_results = self.read_dir_results_stack.last_mut().unwrap();
let top_read_dir_results = self.read_dir_results_stack.last_mut()?;

// 2. If more results in current read dir then process
if let Some(dir_entry_result) = top_read_dir_results.next() {
Expand Down

0 comments on commit a94d14b

Please sign in to comment.