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 cec5c61 commit 7dddd91Copy full SHA for 7dddd91
src/lib.rs
@@ -123,6 +123,22 @@ pub trait NixPath {
123
where F: FnOnce(&CStr) -> T;
124
}
125
126
+impl NixPath for CStr {
127
+ fn len(&self) -> usize {
128
+ self.to_bytes().len()
129
+ }
130
+
131
+ fn with_nix_path<T, F>(&self, f: F) -> Result<T>
132
+ where F: FnOnce(&CStr) -> T {
133
+ // Equivalence with the [u8] impl.
134
+ if self.len() >= PATH_MAX as usize {
135
+ return Err(Error::InvalidPath);
136
137
138
+ Ok(f(self))
139
140
+}
141
142
impl NixPath for [u8] {
143
fn len(&self) -> usize {
144
self.len()
0 commit comments