MCPcopy Create free account
hub / github.com/csskit/csskit / trailing_len

Method trailing_len

crates/css_lexer/src/token.rs:1021–1029  ·  view source on GitHub ↗

Some tokens may have a "trailing" part: - [Kind::Function] will always have an opening `(`. - [Kind::String] may have a closing `"` or `'`. - [Kind::Comment] may have a closing `*/` - [Kind::Url] may have a clsoing `)`. This function returns the length of that, irrespective of the [Kind]. For other kinds not listed, this will return `0`, but for the above kinds it will calculate the leading lengt

(&self)

Source from the content-addressed store, hash-verified

1019 /// `0`, but for the above kinds it will calculate the leading length. This is useful for parsing out the underlying
1020 /// data which is likely to be of greater use.
1021 pub fn trailing_len(&self) -> u32 {
1022 match self.kind() {
1023 Kind::Function | Kind::BadFunction => 1,
1024 Kind::String | Kind::BadString => self.has_close_quote() as u32,
1025 Kind::Comment | Kind::BadComment if self.comment_style().unwrap().is_block() => 2,
1026 Kind::Url | Kind::BadUrl => self.0 & !HALF_LENGTH_MASK,
1027 _ => 0,
1028 }
1029 }
1030
1031 /// Certain kinds have a [PairWise] equivalent:
1032 /// - [Kind::LeftParen] has [Kind::RightParen]

Callers 8

visit_url_or_stringMethod · 0.80
fmt_compacted_identMethod · 0.80
fmt_compacted_urlMethod · 0.80
fmt_expanded_identMethod · 0.80
fmt_expanded_urlMethod · 0.80
eq_ignore_ascii_caseMethod · 0.80
parseMethod · 0.80
parse_ascii_lowerMethod · 0.80

Calls 4

has_close_quoteMethod · 0.80
is_blockMethod · 0.80
comment_styleMethod · 0.80
kindMethod · 0.45

Tested by

no test coverage detected