We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3154b7d commit 5c535c3Copy full SHA for 5c535c3
src/lib.rs
@@ -119,6 +119,22 @@ pub trait NixPath {
119
where F: FnOnce(&CStr) -> T;
120
}
121
122
+impl NixPath for CStr {
123
+ fn len(&self) -> usize {
124
+ self.to_bytes().len()
125
+ }
126
+
127
+ fn with_nix_path<T, F>(&self, f: F) -> Result<T>
128
+ where F: FnOnce(&CStr) -> T {
129
+ // Equivalence with the [u8] impl.
130
+ if self.len() >= PATH_MAX as usize {
131
+ return Err(Error::InvalidPath);
132
133
134
+ Ok(f(self))
135
136
+}
137
138
impl NixPath for [u8] {
139
fn len(&self) -> usize {
140
self.len()
0 commit comments