Coverage Report

Created: 2025-11-11 06:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tempfile-3.23.0/src/error.rs
Line
Count
Source
1
use std::path::PathBuf;
2
use std::{error, fmt, io};
3
4
#[derive(Debug)]
5
struct PathError {
6
    path: PathBuf,
7
    err: io::Error,
8
}
9
10
impl fmt::Display for PathError {
11
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12
0
        write!(f, "{} at path {:?}", self.err, self.path)
13
0
    }
14
}
15
16
impl error::Error for PathError {
17
0
    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
18
0
        self.err.source()
19
0
    }
20
}
21
22
pub(crate) trait IoResultExt<T> {
23
    fn with_err_path<F, P>(self, path: F) -> Self
24
    where
25
        F: FnOnce() -> P,
26
        P: Into<PathBuf>;
27
}
28
29
impl<T> IoResultExt<T> for Result<T, io::Error> {
30
10.5k
    fn with_err_path<F, P>(self, path: F) -> Self
31
10.5k
    where
32
10.5k
        F: FnOnce() -> P,
33
10.5k
        P: Into<PathBuf>,
34
    {
35
10.5k
        self.map_err(|e| {
36
0
            io::Error::new(
37
0
                e.kind(),
38
0
                PathError {
39
0
                    path: path().into(),
40
0
                    err: e,
41
0
                },
42
            )
43
0
        })
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<tempfile::file::NamedTempFile, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::file::NamedTempFile>>::with_err_path::<tempfile::util::create_helper<tempfile::file::NamedTempFile, <tempfile::Builder>::tempfile_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::util::create_helper<std::fs::File, tempfile::file::imp::platform::create_unix::{closure#0}>::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<<tempfile::file::NamedTempFile>::reopen::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::file::create_named::{closure#0}, std::path::PathBuf>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_end::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_vectored::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_string::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_vectored::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::dir::TempDir>::close::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::TempPath>::close::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<tempfile::dir::imp::unix::create::{closure#0}, &std::path::PathBuf>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_exact::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_fmt::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<u64, std::io::error::Error> as tempfile::error::IoResultExt<u64>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Seek>::seek::{closure#0}, &std::path::Path>::{closure#0}
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>::{closure#0}
44
10.5k
    }
Unexecuted instantiation: <core::result::Result<tempfile::dir::TempDir, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::dir::TempDir>>::with_err_path::<tempfile::util::create_helper<tempfile::dir::TempDir, <tempfile::Builder>::tempdir_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<tempfile::file::NamedTempFile, std::io::error::Error> as tempfile::error::IoResultExt<tempfile::file::NamedTempFile>>::with_err_path::<tempfile::util::create_helper<tempfile::file::NamedTempFile, <tempfile::Builder>::tempfile_in<std::path::PathBuf>::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::util::create_helper<std::fs::File, tempfile::file::imp::platform::create_unix::{closure#0}>::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<<tempfile::file::NamedTempFile>::reopen::{closure#0}, &std::path::Path>
<core::result::Result<std::fs::File, std::io::error::Error> as tempfile::error::IoResultExt<std::fs::File>>::with_err_path::<tempfile::file::create_named::{closure#0}, std::path::PathBuf>
Line
Count
Source
30
2.76k
    fn with_err_path<F, P>(self, path: F) -> Self
31
2.76k
    where
32
2.76k
        F: FnOnce() -> P,
33
2.76k
        P: Into<PathBuf>,
34
    {
35
2.76k
        self.map_err(|e| {
36
            io::Error::new(
37
                e.kind(),
38
                PathError {
39
                    path: path().into(),
40
                    err: e,
41
                },
42
            )
43
        })
44
2.76k
    }
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_end::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_vectored::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_to_string::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_vectored::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<usize, std::io::error::Error> as tempfile::error::IoResultExt<usize>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::dir::TempDir>::close::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::TempPath>::close::{closure#0}, &std::path::Path>
<core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<tempfile::dir::imp::unix::create::{closure#0}, &std::path::PathBuf>
Line
Count
Source
30
5.00k
    fn with_err_path<F, P>(self, path: F) -> Self
31
5.00k
    where
32
5.00k
        F: FnOnce() -> P,
33
5.00k
        P: Into<PathBuf>,
34
    {
35
5.00k
        self.map_err(|e| {
36
            io::Error::new(
37
                e.kind(),
38
                PathError {
39
                    path: path().into(),
40
                    err: e,
41
                },
42
            )
43
        })
44
5.00k
    }
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Read>::read_exact::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Write>::write_fmt::{closure#0}, &std::path::Path>
Unexecuted instantiation: <core::result::Result<u64, std::io::error::Error> as tempfile::error::IoResultExt<u64>>::with_err_path::<<&tempfile::file::NamedTempFile as std::io::Seek>::seek::{closure#0}, &std::path::Path>
<core::result::Result<(), std::io::error::Error> as tempfile::error::IoResultExt<()>>::with_err_path::<<tempfile::file::NamedTempFile as std::io::Write>::write_all::{closure#0}, &std::path::Path>
Line
Count
Source
30
2.76k
    fn with_err_path<F, P>(self, path: F) -> Self
31
2.76k
    where
32
2.76k
        F: FnOnce() -> P,
33
2.76k
        P: Into<PathBuf>,
34
    {
35
2.76k
        self.map_err(|e| {
36
            io::Error::new(
37
                e.kind(),
38
                PathError {
39
                    path: path().into(),
40
                    err: e,
41
                },
42
            )
43
        })
44
2.76k
    }
45
}