hecto/src/row.rs

21 lines
434 B
Rust
Raw Normal View History

2021-03-08 10:43:40 -05:00
use std::cmp;
2021-03-08 10:21:06 -05:00
pub struct Row {
string: String,
2021-03-08 10:43:40 -05:00
}
impl From<&str> for Row {
fn from(slice: &str) -> Self {
Self {
string: String::from(slice),
}
}
}
impl Row {
pub fn render(&self, start: usize, end: usize) -> String {
let end = cmp::min(end, self.string.len());
let start = cmp::min(start, end);
self.string.get(start..end).unwrap_or_default().to_string()
}
2021-03-08 10:21:06 -05:00
}