agent: Fix clippy unnecessary_map_or

Fix `unnecessary_map_or` clippy warning as suggested by rust 1.85.1.

```console

warning: this `map_or` can be simplified
    --> rustjail/src/container.rs:1424:20
     |
1424 |                   if namespace
     |  ____________________^
1425 | |                     .path()
1426 | |                     .as_ref()
1427 | |                     .map_or(true, |p| p.as_os_str().is_empty())
     | |_______________________________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
help: use is_none_or instead
     |
1424 ~                 if namespace
1425 +                     .path()
1426 +                     .as_ref().is_none_or(|p| p.as_os_str().is_empty())
     |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-05-26 03:36:09 +00:00
parent f9c76edd23
commit 5a95a65604

View File

@ -450,11 +450,7 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
}
let s = s.unwrap();
if ns
.path()
.as_ref()
.map_or(true, |p| p.as_os_str().is_empty())
{
if ns.path().as_ref().is_none_or(|p| p.as_os_str().is_empty()) {
// skip the pidns since it has been done in parent process.
if *s != CloneFlags::CLONE_NEWPID {
to_new.set(*s, true);
@ -1424,7 +1420,7 @@ pub fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> R
if namespace
.path()
.as_ref()
.map_or(true, |p| p.as_os_str().is_empty())
.is_none_or(|p| p.as_os_str().is_empty())
{
namespace.set_path(Some(PathBuf::from(&ns_path)));
}