littlefs2 icon indicating copy to clipboard operation
littlefs2 copied to clipboard

Support paths without trailing nulls

Open robin-nitrokey opened this issue 7 months ago • 1 comments

Once factor that makes dealing with Paths somewhat awkward at the moment is the requirement for a trailing null. For example, I cannot have a split_at(&self, n: usize) -> (&Path, &Path) function because the first part would not have a trailing null. But allocating a PathBuf would often be wasteful because it might be discarded directly, or may only be used for comparison and not for a littlefs2 API call.

We could support this by introducing a third path type that does not require a trailing null, let’s call it PathView. It could be created without overhead from a PathBuf or Path and could be used for comparison. To use it with a littefs2 API call, it would need to be converted to a PathBuf.

Do you think it is worth having a separate type for this or should we just accept the current limitations?

robin-nitrokey avatar Jul 03 '24 09:07 robin-nitrokey