Skip to content

Commit

Permalink
Fix mismatched unicode feature names (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Felerius authored and mitsuhiko committed Jan 25, 2020
1 parent b88db77 commit 2c29bf0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils.rs
Expand Up @@ -598,24 +598,24 @@ impl<'a> Iterator for AnsiCodeIterator<'a> {
}

fn str_width(s: &str) -> usize {
#[cfg(feature = "unicode")]
#[cfg(feature = "unicode-width")]
{
use unicode_width::UnicodeWidthStr;
s.width()
}
#[cfg(not(feature = "unicode"))]
#[cfg(not(feature = "unicode-width"))]
{
s.chars().count()
}
}

fn char_width(c: char) -> usize {
#[cfg(feature = "unicode")]
#[cfg(feature = "unicode-width")]
{
use unicode_width::UnicodeWidthChar;
c.width().unwrap_or(0)
}
#[cfg(not(feature = "unicode"))]
#[cfg(not(feature = "unicode-width"))]
{
let _c = c;
1
Expand Down Expand Up @@ -744,7 +744,7 @@ fn test_text_width() {
}

#[test]
#[cfg(feature = "unicode")]
#[cfg(feature = "unicode-width")]
fn test_truncate_str() {
let s = format!("foo {}", style("bar").red().force_styling(true));
assert_eq!(
Expand Down

0 comments on commit 2c29bf0

Please sign in to comment.