Home / File/ cursor.rs — tailwindcss Source File

cursor.rs — tailwindcss Source File

Architecture documentation for cursor.rs, a rust file in the tailwindcss codebase. 3 imports, 0 dependents.

File rust OxideEngine Extractor 3 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  3d889371_52ae_87e1_810f_7e71098819d9["cursor.rs"]
  0d442d7d_9957_fd69_fade_182cf1c6aed0["super::*"]
  3d889371_52ae_87e1_810f_7e71098819d9 --> 0d442d7d_9957_fd69_fade_182cf1c6aed0
  148a0379_62c6_86e3_d9b3_de1fdebd7cfb["std::"]
  3d889371_52ae_87e1_810f_7e71098819d9 --> 148a0379_62c6_86e3_d9b3_de1fdebd7cfb
  e4088d34_b5b4_ec51_b975_557a1536ec76["pretty_assertions::assert_eq"]
  3d889371_52ae_87e1_810f_7e71098819d9 --> e4088d34_b5b4_ec51_b975_557a1536ec76
  style 3d889371_52ae_87e1_810f_7e71098819d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use std::{ascii::escape_default, fmt::Display};

#[derive(Debug, Clone)]
pub struct Cursor<'a> {
    // The input we're scanning
    pub input: &'a [u8],

    // The location of the cursor in the input
    pub pos: usize,

    /// Is the cursor at the start of the input
    pub at_start: bool,

    /// Is the cursor at the end of the input
    pub at_end: bool,

    /// The previously consumed character
    /// If `at_start` is true, this will be NUL
    pub prev: u8,

    /// The current character
    pub curr: u8,

    /// The upcoming character (if any)
    /// If `at_end` is true, this will be NUL
    pub next: u8,
}

impl<'a> Cursor<'a> {
    pub fn new(input: &'a [u8]) -> Self {
        let mut cursor = Self {
            input,
            pos: 0,
            at_start: true,
            at_end: false,
            prev: 0x00,
            curr: 0x00,
            next: 0x00,
        };
        cursor.move_to(0);
        cursor
    }

    pub fn advance_by(&mut self, amount: usize) {
        self.move_to(self.pos.saturating_add(amount));
    }

    #[inline(always)]
    pub fn advance(&mut self) {
        self.pos += 1;

        self.prev = self.curr;
        self.curr = self.next;
        self.next = *self
            .input
            .get(self.pos.saturating_add(1))
            .unwrap_or(&0x00u8);
    }

    #[inline(always)]
// ... (101 more lines)

Domain

Subdomains

Dependencies

  • pretty_assertions::assert_eq
  • std::
  • super::*

Frequently Asked Questions

What does cursor.rs do?
cursor.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in cursor.rs?
cursor.rs defines 7 function(s): advance, advance_by, advance_twice, fmt, move_to, new, test_cursor.
What does cursor.rs depend on?
cursor.rs imports 3 module(s): pretty_assertions::assert_eq, std::, super::*.
Where is cursor.rs in the architecture?
cursor.rs is located at crates/oxide/src/cursor.rs (domain: OxideEngine, subdomain: Extractor, directory: crates/oxide/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free