Skip to content

Commit 5387c54

Browse files
Fix Rust clippy: collapse nested if-let and scope MutexGuard before await
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 80b4291 commit 5387c54

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

rust/tests/e2e/session_fs_sqlite.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ impl SessionFsProvider for InMemorySqliteProvider {
140140
let prefix = format!("{}/", path.trim_end_matches('/'));
141141
let mut names = std::collections::BTreeSet::new();
142142
for p in files.keys().chain(dirs.iter()) {
143-
if let Some(rest) = p.strip_prefix(&prefix) {
144-
if let Some(name) = rest.split('/').next().filter(|n| !n.is_empty()) {
145-
names.insert(name.to_string());
146-
}
143+
if let Some(name) = p
144+
.strip_prefix(&prefix)
145+
.and_then(|rest| rest.split('/').next())
146+
.filter(|n| !n.is_empty())
147+
{
148+
names.insert(name.to_string());
147149
}
148150
}
149151
Ok(names.into_iter().collect())
@@ -155,19 +157,23 @@ impl SessionFsProvider for InMemorySqliteProvider {
155157
let prefix = format!("{}/", path.trim_end_matches('/'));
156158
let mut entries: HashMap<String, DirEntryKind> = HashMap::new();
157159
for d in dirs.iter() {
158-
if let Some(rest) = d.strip_prefix(&prefix) {
159-
if let Some(name) = rest.split('/').next().filter(|n| !n.is_empty()) {
160-
entries.insert(name.to_string(), DirEntryKind::Directory);
161-
}
160+
if let Some(name) = d
161+
.strip_prefix(&prefix)
162+
.and_then(|rest| rest.split('/').next())
163+
.filter(|n| !n.is_empty())
164+
{
165+
entries.insert(name.to_string(), DirEntryKind::Directory);
162166
}
163167
}
164168
for f in files.keys() {
165-
if let Some(rest) = f.strip_prefix(&prefix) {
166-
if let Some(name) = rest.split('/').next().filter(|n| !n.is_empty()) {
167-
entries
168-
.entry(name.to_string())
169-
.or_insert(DirEntryKind::File);
170-
}
169+
if let Some(name) = f
170+
.strip_prefix(&prefix)
171+
.and_then(|rest| rest.split('/').next())
172+
.filter(|n| !n.is_empty())
173+
{
174+
entries
175+
.entry(name.to_string())
176+
.or_insert(DirEntryKind::File);
171177
}
172178
}
173179
let mut result: Vec<DirEntry> = entries

0 commit comments

Comments
 (0)