-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
102 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ┌───────────────────────────────────────────────────────────────────────────┐ | ||
// │ │ | ||
// │ ██████╗ ██████╗ ██████╗ Copyright (C) 2022, The Prospective Company │ | ||
// │ ██╔══██╗██╔══██╗██╔═══██╗ │ | ||
// │ ██████╔╝██████╔╝██║ ██║ This file is part of the Procss library, │ | ||
// │ ██╔═══╝ ██╔══██╗██║ ██║ distributed under the terms of the │ | ||
// │ ██║ ██║ ██║╚██████╔╝ Apache License 2.0. The full license can │ | ||
// │ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ be found in the LICENSE file. │ | ||
// │ │ | ||
// └───────────────────────────────────────────────────────────────────────────┘ | ||
|
||
use std::collections::HashSet; | ||
|
||
use crate::ast::Ruleset::{self}; | ||
use crate::ast::*; | ||
|
||
pub fn deduplicate(css: &mut Css) { | ||
let mut seen: HashSet<&Ruleset<'_, Rule<'_>>> = HashSet::default(); | ||
let res = css | ||
.iter() | ||
.rev() | ||
.filter(|x| seen.insert(*x)) | ||
.rev() | ||
.cloned() | ||
.collect(); | ||
*css = crate::ast::Css(res); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ┌───────────────────────────────────────────────────────────────────────────┐ | ||
// │ │ | ||
// │ ██████╗ ██████╗ ██████╗ Copyright (C) 2022, The Prospective Company │ | ||
// │ ██╔══██╗██╔══██╗██╔═══██╗ │ | ||
// │ ██████╔╝██████╔╝██║ ██║ This file is part of the Procss library, │ | ||
// │ ██╔═══╝ ██╔══██╗██║ ██║ distributed under the terms of the │ | ||
// │ ██║ ██║ ██║╚██████╔╝ Apache License 2.0. The full license can │ | ||
// │ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ be found in the LICENSE file. │ | ||
// │ │ | ||
// └───────────────────────────────────────────────────────────────────────────┘ | ||
|
||
use crate::ast::Ruleset::{self}; | ||
use crate::ast::*; | ||
|
||
pub fn remove_mixin(css: &mut Css) { | ||
let reduced = css | ||
.iter() | ||
.filter(|&x| { | ||
!matches!( | ||
x, | ||
Ruleset::QualRule(QualRule("mixin", _)) | ||
| Ruleset::QualNestedRuleset(QualNestedRuleset(QualRule("mixin", _), _)) | ||
| Ruleset::QualRuleset(QualRuleset(QualRule("mixin", _), _)) | ||
) | ||
}) | ||
.cloned(); | ||
|
||
*css = crate::ast::Css(reduced.collect()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters