1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This file is part of helpers4.
// Copyright (C) 2025 baxyz
// SPDX-License-Identifier: LGPL-3.0-or-later
use io;
use Path;
/// Reads a whole file as text, giving `None` instead of an error when it does not exist.
///
/// Every other failure (permissions, a directory, invalid UTF-8) is still an error: only "not
/// found" means "no value".
///
/// # Arguments
///
/// - `path` - The file to read.
///
/// # Errors
///
/// Any [`io::Error`] from [`std::fs::read_to_string`] except [`io::ErrorKind::NotFound`].
///
/// # Examples
///
/// ```
/// use helpers4::fs::read_to_string_opt;
///
/// assert_eq!(read_to_string_opt("/definitely/not/here.txt")?, None);
/// # Ok::<(), std::io::Error>(())
/// ```
// Non-generic, so every branch is one instantiation to cover, not one per path type.