move util hex_char_for() to utils.rs

This commit is contained in:
ConnorSkees 2020-04-19 15:50:22 -04:00
parent e820395cc5
commit 18a04b2669
2 changed files with 11 additions and 10 deletions

View File

@ -746,3 +746,13 @@ pub(crate) fn read_until_char<I: Iterator<Item = Token>>(
pub(crate) fn is_ident_char(c: char) -> bool {
c.is_ascii_alphabetic() || c == '_' || c == '\\' || (!c.is_ascii() && !c.is_control())
}
pub(crate) fn hex_char_for(number: u32) -> char {
assert!(number < 0x10);
std::char::from_u32(if number < 0xA {
0x30 + number
} else {
0x61 - 0xA + number
})
.unwrap()
}

View File

@ -7,6 +7,7 @@ use crate::color::Color;
use crate::common::{Brackets, ListSeparator, Op, QuoteKind};
use crate::error::SassResult;
use crate::unit::{Unit, UNIT_CONVERSION_TABLE};
use crate::utils::hex_char_for;
use css_function::is_special_function;
pub(crate) use map::SassMap;
@ -39,16 +40,6 @@ pub(crate) enum Value {
Function(SassFunction),
}
fn hex_char_for(number: u32) -> char {
assert!(number < 0x10);
std::char::from_u32(if number < 0xA {
0x30 + number
} else {
0x61 - 0xA + number
})
.unwrap()
}
fn visit_quoted_string(buf: &mut String, force_double_quote: bool, string: &str) -> SassResult<()> {
let mut has_single_quote = false;
let mut has_double_quote = false;