mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 13:38:43 +00:00
Fix CratesToml::write_to_{writer, file}
Make them consistent with `Crates2Json::write_to_{writer, file}` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
0a753f3e4b
commit
6ce48419b6
1 changed files with 5 additions and 7 deletions
|
@ -47,18 +47,16 @@ impl CratesToml {
|
|||
self.write_to_path(Self::default_path()?)
|
||||
}
|
||||
|
||||
pub fn write_to_writer<W: io::Write>(
|
||||
&self,
|
||||
mut writer: W,
|
||||
) -> Result<u64, CratesTomlParseError> {
|
||||
pub fn write_to_writer<W: io::Write>(&self, mut writer: W) -> Result<(), CratesTomlParseError> {
|
||||
let data = toml::to_vec(&self)?;
|
||||
writer.write_all(&data)?;
|
||||
Ok(data.len().try_into().unwrap())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_to_file(&self, file: &mut fs::File) -> Result<(), CratesTomlParseError> {
|
||||
let cnt = self.write_to_writer(&mut *file)?;
|
||||
file.set_len(cnt)?;
|
||||
self.write_to_writer(&mut *file)?;
|
||||
let pos = file.stream_position()?;
|
||||
file.set_len(pos)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue