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)
| 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] |
no test coverage detected