2019-07-22 15:14:39 +03:00
|
|
|
pub mod grapheme_clusters;
|
2019-07-27 01:56:07 +03:00
|
|
|
pub mod line_break;
|
|
|
|
mod tables;
|
|
|
|
mod types;
|
2019-11-16 20:19:02 +02:00
|
|
|
pub use types::Reflow;
|
2019-07-22 15:14:39 +03:00
|
|
|
pub mod wcwidth;
|
|
|
|
pub use grapheme_clusters::*;
|
2019-07-27 01:56:07 +03:00
|
|
|
pub use line_break::*;
|
2019-07-22 15:14:39 +03:00
|
|
|
pub use wcwidth::*;
|
2019-11-22 14:17:09 +02:00
|
|
|
|
|
|
|
pub trait Truncate {
|
|
|
|
fn truncate_at_boundary(self, new_len: usize);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Truncate for &mut String {
|
|
|
|
fn truncate_at_boundary(self, mut new_len: usize) {
|
|
|
|
while new_len > 0 && !self.is_char_boundary(new_len) {
|
|
|
|
new_len -= 1;
|
|
|
|
}
|
|
|
|
String::truncate(self, new_len);
|
|
|
|
}
|
|
|
|
}
|