Switch to file ids

This commit is contained in:
Aleksey Kladov 2018-08-15 17:24:20 +03:00
parent 109658332a
commit 9f6cf42c5f
8 changed files with 215 additions and 127 deletions

View file

@ -37,7 +37,6 @@ pub type Result<T> = ::std::result::Result<T, ::failure::Error>;
const INDEXING_THRESHOLD: usize = 128;
pub struct WorldState {
next_file_id: u32,
data: Arc<WorldData>
}
@ -47,12 +46,11 @@ pub struct World {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileId(u32);
pub struct FileId(pub u32);
impl WorldState {
pub fn new() -> WorldState {
WorldState {
next_file_id: 0,
data: Arc::new(WorldData::default())
}
}
@ -61,12 +59,6 @@ impl WorldState {
World { data: self.data.clone() }
}
pub fn new_file_id(&mut self) -> FileId {
let id = FileId(self.next_file_id);
self.next_file_id += 1;
id
}
pub fn change_file(&mut self, file_id: FileId, text: Option<String>) {
self.change_files(::std::iter::once((file_id, text)));
}