Home / Function/ next() — tailwindcss Function Reference

next() — tailwindcss Function Reference

Architecture documentation for the next() function in modifier_machine.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  e83ca0fe_bf7a_1e0a_e296_3b00cd3f5fb9["next()"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b["modifier_machine.rs"]
  e83ca0fe_bf7a_1e0a_e296_3b00cd3f5fb9 -->|defined in| 2c61e6dd_1b50_c9dd_3887_d30248d91c0b
  style e83ca0fe_bf7a_1e0a_e296_3b00cd3f5fb9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/modifier_machine.rs lines 32–96

    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        // A modifier must start with a `/`, everything else is not a valid start of a modifier
        if Class::Slash != cursor.curr.into() {
            return MachineState::Idle;
        }

        let start_pos = cursor.pos;
        cursor.advance();

        match cursor.curr.into() {
            // Start of an arbitrary value:
            //
            // ```
            // bg-red-500/[20%]
            //            ^^^^^
            // ```
            Class::OpenBracket => match self.arbitrary_value_machine.next(cursor) {
                MachineState::Idle => self.restart(),
                MachineState::Done(_) => self.done(start_pos, cursor),
            },

            // Start of an arbitrary variable:
            //
            // ```
            // bg-red-500/(--my-opacity)
            //            ^^^^^^^^^^^^^^
            // ```
            Class::OpenParen => match self.arbitrary_variable_machine.next(cursor) {
                MachineState::Idle => self.restart(),
                MachineState::Done(_) => self.done(start_pos, cursor),
            },

            // Start of a named modifier:
            //
            // ```
            // bg-red-500/20
            //            ^^
            // ```
            Class::ValidStart => {
                let len = cursor.input.len();
                while cursor.pos < len {
                    match cursor.curr.into() {
                        Class::ValidStart | Class::ValidInside => {
                            match cursor.next.into() {
                                // Only valid characters are allowed, if followed by another valid character
                                Class::ValidStart | Class::ValidInside => cursor.advance(),

                                // Valid character, but at the end of the modifier, this ends the
                                // modifier
                                _ => return self.done(start_pos, cursor),
                            }
                        }

                        // Anything else is invalid, end of the modifier
                        _ => return self.restart(),
                    }
                }

                MachineState::Idle
            }

            // Anything else is not a valid start of a modifier
            _ => MachineState::Idle,
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does next() do?
next() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/modifier_machine.rs.
Where is next() defined?
next() is defined in crates/oxide/src/extractor/modifier_machine.rs at line 32.

Analyze Your Own Codebase

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

Try Supermodel Free