pub struct SplitedCode { /* private fields */ }
Expand description
A code that has been split into lines and characters for processing
§Example
use trees_lang::compile::{SplitedCode, split_code, CharWidthMode, CompileConfig, CodeCharacter};
// Split each character
let mut splited_code: SplitedCode = split_code(
&vec![" ┌─".to_owned()],
&CompileConfig {
char_width: CharWidthMode::Mono
}
);
// Get each characters' position
// (It is useful if char_width is not Mono)
assert_eq!(splited_code.enumurate_x(0).collect::<Vec<_>>(), vec![0, 1, 2]);
// Get char of target position
assert_eq!(splited_code.get(1, 0), Some(CodeCharacter {
char: "┌".to_owned(), x: 1, len: 1
}));
Implementations§
Source§impl SplitedCode
impl SplitedCode
Sourcepub fn get(&self, x: usize, y: usize) -> Option<CodeCharacter>
pub fn get(&self, x: usize, y: usize) -> Option<CodeCharacter>
Retrieves a specific character at position (x, y)
from the split code.
If the position is out of bounds or does not contain a character, returns None
.
Sourcepub fn get_slice_of_line(
&self,
x_min_exclusive: usize,
x_max_exclusive: usize,
y: usize,
) -> Option<String>
pub fn get_slice_of_line( &self, x_min_exclusive: usize, x_max_exclusive: usize, y: usize, ) -> Option<String>
Retrieves a slice of characters from the specified line between x_min_exclusive
and x_max_exclusive
.
If the range is invalid or out of bounds, returns None
.
Sourcepub fn left_x(&self, x: usize, y: usize) -> Option<usize>
pub fn left_x(&self, x: usize, y: usize) -> Option<usize>
Retrieves the position of the character to the left of the given (x, y)
position.
If there is no character to the left, returns None
.
Trait Implementations§
Source§impl Clone for SplitedCode
impl Clone for SplitedCode
Source§fn clone(&self) -> SplitedCode
fn clone(&self) -> SplitedCode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SplitedCode
impl Debug for SplitedCode
Source§impl PartialEq for SplitedCode
impl PartialEq for SplitedCode
impl Eq for SplitedCode
impl StructuralPartialEq for SplitedCode
Auto Trait Implementations§
impl Freeze for SplitedCode
impl RefUnwindSafe for SplitedCode
impl Send for SplitedCode
impl Sync for SplitedCode
impl Unpin for SplitedCode
impl UnwindSafe for SplitedCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more