natter/src/intermediate/src_block.rs

23 lines
541 B
Rust
Raw Normal View History

2023-10-27 17:08:58 -04:00
use crate::error::CustomError;
use super::registry::Registry;
2023-10-29 15:36:15 -04:00
#[derive(Debug, Clone)]
pub(crate) struct ISrcBlock {
pub(crate) lines: Vec<String>,
}
2023-10-27 17:08:58 -04:00
impl ISrcBlock {
2023-10-29 14:14:10 -04:00
pub(crate) async fn new<'b, 'parse>(
registry: &'b mut Registry<'parse>,
original: &'b organic::types::SrcBlock<'parse>,
2023-10-27 17:08:58 -04:00
) -> Result<ISrcBlock, CustomError> {
2023-10-29 10:32:05 -04:00
let lines = original
.contents
.split_inclusive('\n')
2023-10-29 10:32:05 -04:00
.map(|s| s.to_owned())
.collect();
Ok(ISrcBlock { lines })
2023-10-27 17:08:58 -04:00
}
}