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 Oxide PreProcessors 3 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  38e073c3_a357_d869_e8e1_3fb53595a170["cursor.rs"]
  989a37f5_5142_b5ef_68dc_26a0e03931c5["super::*"]
  38e073c3_a357_d869_e8e1_3fb53595a170 --> 989a37f5_5142_b5ef_68dc_26a0e03931c5
  cf006a3e_51d2_5361_1dd4_6d904d0bfa75["std::"]
  38e073c3_a357_d869_e8e1_3fb53595a170 --> cf006a3e_51d2_5361_1dd4_6d904d0bfa75
  433675ca_8d0e_feff_42a5_b3f666878cca["pretty_assertions::assert_eq"]
  38e073c3_a357_d869_e8e1_3fb53595a170 --> 433675ca_8d0e_feff_42a5_b3f666878cca
  style 38e073c3_a357_d869_e8e1_3fb53595a170 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 Oxide domain, PreProcessors 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: Oxide, subdomain: PreProcessors, directory: crates/oxide/src).

Analyze Your Own Codebase

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

Try Supermodel Free