feat: Introduce the WriteToBytes trait

This commit is contained in:
Clément Renault 2019-02-17 16:32:43 +01:00
parent 9e7261a48f
commit 8014857ebf
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,8 @@ pub mod data;
pub mod rank;
pub mod tokenizer;
mod common_words;
mod shared_data_cursor;
mod write_to_bytes;
use serde_derive::{Serialize, Deserialize};

9
src/write_to_bytes.rs Normal file
View File

@ -0,0 +1,9 @@
pub trait WriteToBytes {
fn write_to_bytes(&self, bytes: &mut Vec<u8>);
fn into_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();
self.write_to_bytes(&mut bytes);
bytes
}
}