Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug, Clone)]
- pub enum ChunkContent<'a> {
- Text(&'a str),
- Tokens(Box<Vec<Token>>),
- Block(Box<Branch<'a>>),
- }
- #[derive(Debug, Clone)]
- pub struct Chunk<'a> {
- pub content: ChunkContent<'a>,
- }
- #[derive(Debug, Clone)]
- pub struct Branch<'a> {
- pub content: Vec<Chunk<'a>>,
- }
- //
- // other place in other module
- //
- pub fn tokenize_branch_mutate(branch: &mut Branch<'a>) {
- for mut chunk in branch.content.iter() {
- match chunk.content
- ChunkContent::Text(t) => {
- // !!!
- // Cannot assign immutable field 'chunk.content'
- chunk.content = ChunkContent::Tokens(Box::new(Self::tokenize(t)));
- },
- ChunkContent::Block(ref mut b) => { // Cannot borrow immutable private field '... Block).0' as mutable
- Self::tokenize_branch_mutate(b);
- },
- _ => continue,
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement