Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider chars using multiple unicode codepoints #41

Merged
merged 1 commit into from Sep 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/datatype.rs
Expand Up @@ -121,12 +121,12 @@ pub fn trunc_strings(vec_col: Vec<&str>, width: usize) -> Vec<String> {
// add
.map(|string| format_if_num(&string))
.map(|mut string| {
if string.len() > width {
let len = string.chars().count();
if len > width {
string.truncate(width - 1);
[string, ellipsis.to_string()].join(" ")
} else {
let l = string.len();
let add_space = width - l + 1;
let add_space = width - len + 1;
let borrowed_string: &str = &" ".repeat(add_space);
[string, "".to_string()].join(borrowed_string)
}
Expand All @@ -136,9 +136,8 @@ pub fn trunc_strings(vec_col: Vec<&str>, width: usize) -> Vec<String> {
}
pub fn header_len_str(vec_col: Vec<&str>) -> Vec<usize> {
let v = vec_col
.into_iter()
.map(String::from)
.map(|string| string.len())
.iter()
.map(|&string| string.chars().count())
.collect::<Vec<usize>>();
return v;
}
Expand Down