Add a take_all() method to Comments. (#552)

This commit is contained in:
David Sherret 2020-01-01 23:21:43 -05:00 committed by 강동윤
parent 4f76cddebd
commit bac1cb52a3

View File

@ -3,6 +3,7 @@ use crate::{
syntax_pos::{BytePos, Span},
};
use chashmap::{CHashMap, ReadGuard};
use std::collections::HashMap;
type CommentMap = CHashMap<BytePos, Vec<Comment>>;
@ -70,6 +71,19 @@ impl Comments {
});
}
}
/// Takes all the comments as (leading, trailing).
pub fn take_all(
self,
) -> (
HashMap<BytePos, Vec<Comment>>,
HashMap<BytePos, Vec<Comment>>,
) {
(
self.leading.into_iter().collect(),
self.trailing.into_iter().collect(),
)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]