Home / Function/ extract() — tailwindcss Function Reference

extract() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a07f5c0a_137c_8e35_bcb0_fe65e36c6864["extract()"]
  d865d4fd_bb15_6d9a_a900_10e82a6856fb["mod.rs"]
  a07f5c0a_137c_8e35_bcb0_fe65e36c6864 -->|defined in| d865d4fd_bb15_6d9a_a900_10e82a6856fb
  0f8d329e_0ee0_3682_91d0_989b1ec14827["get_candidates_with_positions()"]
  0f8d329e_0ee0_3682_91d0_989b1ec14827 -->|calls| a07f5c0a_137c_8e35_bcb0_fe65e36c6864
  90127900_ccd6_309f_f962_1776d09d86f4["extract_css_variables()"]
  90127900_ccd6_309f_f962_1776d09d86f4 -->|calls| a07f5c0a_137c_8e35_bcb0_fe65e36c6864
  e4abe4bd_bf54_17e9_0dc2_bc83afb1e3a5["parse_all_blobs()"]
  e4abe4bd_bf54_17e9_0dc2_bc83afb1e3a5 -->|calls| a07f5c0a_137c_8e35_bcb0_fe65e36c6864
  style a07f5c0a_137c_8e35_bcb0_fe65e36c6864 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/scanner/mod.rs lines 527–564

fn extract<H>(blobs: Vec<Vec<u8>>, handle: H) -> Vec<String>
where
    H: Fn(Extractor) -> Vec<Extracted> + std::marker::Sync,
{
    let mut result: Vec<_> = blobs
        .par_iter()
        .flat_map(|blob| blob.par_split(|x| *x == b'\n'))
        .filter_map(|blob| {
            if blob.is_empty() {
                return None;
            }

            let extracted = handle(crate::extractor::Extractor::new(blob));
            if extracted.is_empty() {
                return None;
            }

            Some(FxHashSet::from_iter(extracted.into_iter().map(
                |x| match x {
                    Extracted::Candidate(bytes) => bytes,
                    Extracted::CssVariable(bytes) => bytes,
                },
            )))
        })
        .reduce(Default::default, |mut a, b| {
            a.extend(b);
            a
        })
        .into_iter()
        .map(|s| unsafe { String::from_utf8_unchecked(s.to_vec()) })
        .collect();

    // SAFETY: Unstable sort is faster and in this scenario it's also safe because we are
    //         guaranteed to have unique candidates.
    result.par_sort_unstable();

    result
}

Domain

Subdomains

Frequently Asked Questions

What does extract() do?
extract() is a function in the tailwindcss codebase, defined in crates/oxide/src/scanner/mod.rs.
Where is extract() defined?
extract() is defined in crates/oxide/src/scanner/mod.rs at line 527.
What calls extract()?
extract() is called by 3 function(s): extract_css_variables, get_candidates_with_positions, parse_all_blobs.

Analyze Your Own Codebase

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

Try Supermodel Free