Comments (4)
Thanks for the suggestion! I suspect the addition of the Into<PathBuf>
bound on everything means we can't be as good as the standard library on this (since we typically only want to call .into()
in the error path), but there are probably some places we can improve.
from fs-err.
I don't quite see why Into<PathBuf>
is required though? I would expect that monomorphic private functions would just take &Path
as an argument, and call .to_path_buf()
on the error path. I don't think this meaningfully changes the allocations -- if the caller has only &Path
, then the behavior is the same. If the caller has a PathBuf
and is ready to sacrifice it to call an fs
method, then, yeah, we do an extra allocation on the error path, but:
- this is a cold path
- given that we require an owned path in this case, this amortizises to the same number of allocations. Ie, you can't construct a loop where the number of allocations goes from O(1) to O(N)
from fs-err.
Good points. I believe constructing a custom io::Error
already does two allocations so cloning the path as well is probably OK.
from fs-err.
The change is straightforward except for File
constructors and the three functions which construct a File
internally (see #31). Those need a PathBuf
even on the hot path. Is the performance hit of always cloning big enough that it should be avoided?
from fs-err.
Related Issues (19)
- Use wrapper around std::io::Error instead of custom error type? HOT 2
- fs::create_dir and fs::create_dir_all
- fs::remove APIs
- Changelog
- fs::metadata
- Fine-grained error messages for `remove_dir_all` HOT 4
- Fine-grained error messages for `create_dir_all` HOT 1
- Missing functions HOT 2
- Missing structs HOT 2
- Is localisation of error messages in scope for this project? HOT 1
- path type different than std::fs::File HOT 5
- Provide a `fn file_mut(&mut self) -> &mut std::fs::File` HOT 3
- Add support for `tokio::fs` HOT 1
- fs::read_dir API HOT 1
- Operability with tokio_stream HOT 1
- More comprehensive rustdocs HOT 5
- fs::copy API HOT 1
- Marketing/public docs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fs-err.