Home / Function/ extract() — tailwindcss Function Reference

extract() — tailwindcss Function Reference

Architecture documentation for the extract() function in mod.rs from the tailwindcss codebase.

Function rust RustCore MachineExtractor calls 5 called by 3

Entity Profile

Dependency Diagram

graph TD
  422ad34b_4317_4855_30c2_d1ae1b67d97a["extract()"]
  6706ee6b_9877_56dd_87bd_9133948b5065["extract_sorted_candidates()"]
  6706ee6b_9877_56dd_87bd_9133948b5065 -->|calls| 422ad34b_4317_4855_30c2_d1ae1b67d97a
  ba82056e_1ee6_37b6_efbc_82b2eb5c14f1["extract_sorted_css_variables()"]
  ba82056e_1ee6_37b6_efbc_82b2eb5c14f1 -->|calls| 422ad34b_4317_4855_30c2_d1ae1b67d97a
  9dc33f0f_7581_bedd_6ea6_c3a243024716["test_extract_performance()"]
  9dc33f0f_7581_bedd_6ea6_c3a243024716 -->|calls| 422ad34b_4317_4855_30c2_d1ae1b67d97a
  435a321a_a1e2_cb4f_7579_0ca15cb86434["advance()"]
  422ad34b_4317_4855_30c2_d1ae1b67d97a -->|calls| 435a321a_a1e2_cb4f_7579_0ca15cb86434
  5a97c1ff_d6d8_407b_cdd5_f7b3455d1d2c["slice()"]
  422ad34b_4317_4855_30c2_d1ae1b67d97a -->|calls| 5a97c1ff_d6d8_407b_cdd5_f7b3455d1d2c
  877a213e_88d9_c372_5e99_15a0654fc974["extract_sub_candidates()"]
  422ad34b_4317_4855_30c2_d1ae1b67d97a -->|calls| 877a213e_88d9_c372_5e99_15a0654fc974
  1420ecae_486c_5643_9c41_1d010f3fc55e["drop_covered_spans()"]
  422ad34b_4317_4855_30c2_d1ae1b67d97a -->|calls| 1420ecae_486c_5643_9c41_1d010f3fc55e
  91d6a0dd_e315_a957_62e1_9fe3920d5d79["next()"]
  422ad34b_4317_4855_30c2_d1ae1b67d97a -->|calls| 91d6a0dd_e315_a957_62e1_9fe3920d5d79
  style 422ad34b_4317_4855_30c2_d1ae1b67d97a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/mod.rs lines 74–141

    pub fn extract(&mut self) -> Vec<Extracted<'a>> {
        // Candidates found by inner candidate machines. If the outer machine finds a solution, we
        // can discard the inner machines. Otherwise, we can keep the candidates from the inner
        // machines.
        let mut in_flight_spans: Vec<Span> = Vec::with_capacity(15);

        // All the extracted values
        let mut extracted = Vec::with_capacity(100);

        let len = self.cursor.input.len();

        // CSS Variable extractor
        {
            let cursor = &mut self.cursor.clone();
            while cursor.pos < len {
                if cursor.curr.is_ascii_whitespace() {
                    cursor.advance();
                    continue;
                }

                if let MachineState::Done(span) = self.css_variable_machine.next(cursor) {
                    extracted.push(Extracted::CssVariable(span.slice(self.cursor.input)));
                }

                cursor.advance();
            }
        }

        // Candidate extractor
        {
            let cursor = &mut self.cursor.clone();

            while cursor.pos < len {
                if cursor.curr.is_ascii_whitespace() {
                    cursor.advance();
                    continue;
                }

                let before = cursor.pos;
                match self.candidate_machine.next(cursor) {
                    MachineState::Done(span) => {
                        in_flight_spans.push(span);
                        extract_sub_candidates(before..span.start, cursor, &mut in_flight_spans);
                    }
                    MachineState::Idle => {
                        extract_sub_candidates(
                            before..cursor.pos.min(cursor.input.len()),
                            cursor,
                            &mut in_flight_spans,
                        );
                    }
                }

                cursor.advance();
            }

            // Commit the remaining in-flight spans as extracted candidates
            if !in_flight_spans.is_empty() {
                extracted.extend(
                    drop_covered_spans(in_flight_spans)
                        .iter()
                        .map(|span| Extracted::Candidate(span.slice(self.cursor.input))),
                );
            }
        }

        extracted
    }

Domain

Subdomains

Frequently Asked Questions

What does extract() do?
extract() is a function in the tailwindcss codebase.
What does extract() call?
extract() calls 5 function(s): advance, drop_covered_spans, extract_sub_candidates, next, slice.
What calls extract()?
extract() is called by 3 function(s): extract_sorted_candidates, extract_sorted_css_variables, test_extract_performance.

Analyze Your Own Codebase

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

Try Supermodel Free