helix
helix copied to clipboard
refactor: tokio::fs instead of std::fs, idiomatic error handling
- Standardized operations to use the existing alias
use tokio::fsinstead of mixingtokio::fs,fs, andstd::fs. https://github.com/helix-editor/helix/blob/2bd7452fe0309e273d06280d15caad6943034377/helix-view/src/document.rs#L989 - Refactored error handling to use
if let Err(e)instead ofmap_err(...log::error!)for better readability and idiomatic Rust style.
If I understand the tokio::fs stuff correctly, calling any function there is equivalent to calling tokio::task::spawn_blocking and then using std::fs. Since we don't await any messages or otherwise require async in this function, it's probably lower overhead to call tokio::task::spawn_blocking directly and use std::fs within.
Yes, and spawn_blocking in rust is costly, given that there is a lock and stuff. But I guess we can go with developer ergonomics and code readability here instead.