FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

parser: Remove ParserInput. by emilio · Pull Request #446 · servo/rust-cssparser · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .lock  (1) .rs  (9) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 11 additions & 11 deletions color/lib.rs
This file contains hidden or 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
Expand Up @@ -44,7 +44,7 @@ where
/// value on success.
pub fn parse_color_with<'i, P>(
color_parser: &P,
input: &mut Parser<'i, '_>,
input: &mut Parser<'i>,
) -> Result<P::Output, ParseError<P::Error>>
where
P: ColorParser<'i>,
Expand Down Expand Up @@ -112,7 +112,7 @@ where
/// Parse the alpha component by itself from either number or percentage,
/// clipping the result to [0.0..1.0].
#[inline]
fn parse_alpha_component<'i, 't, P>(
fn parse_alpha_component<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<f32, ParseError<P::Error>>
Expand All @@ -125,7 +125,7 @@ where
.clamp(0.0, OPAQUE))
}

fn parse_legacy_alpha<'i, 't, P>(
fn parse_legacy_alpha<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<f32, ParseError<P::Error>>
Expand All @@ -140,7 +140,7 @@ where
})
}

fn parse_modern_alpha<'i, 't, P>(
fn parse_modern_alpha<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<Option<f32>, ParseError<P::Error>>
Expand All @@ -156,7 +156,7 @@ where
}

#[inline]
fn parse_rgb<'i, 't, P>(
fn parse_rgb<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<P::Output, ParseError<P::Error>>
Expand Down Expand Up @@ -222,7 +222,7 @@ where
///
/// <https://drafts.csswg.org/css-color/#the-hsl-notation>
#[inline]
fn parse_hsl<'i, 't, P>(
fn parse_hsl<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<P::Output, ParseError<P::Error>>
Expand Down Expand Up @@ -261,7 +261,7 @@ where
///
/// <https://drafts.csswg.org/css-color/#the-hbw-notation>
#[inline]
fn parse_hwb<'i, 't, P>(
fn parse_hwb<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<P::Output, ParseError<P::Error>>
Expand Down Expand Up @@ -340,7 +340,7 @@ type IntoColorFn<Output> =
fn(l: Option<f32>, a: Option<f32>, b: Option<f32>, alpha: Option<f32>) -> Output;

#[inline]
fn parse_lab_like<'i, 't, P>(
fn parse_lab_like<'i, P>(
color_parser: &P,
arguments: &mut Parser,
lightness_range: f32,
Expand All @@ -366,7 +366,7 @@ where
}

#[inline]
fn parse_lch_like<'i, 't, P>(
fn parse_lch_like<'i, P>(
color_parser: &P,
arguments: &mut Parser,
lightness_range: f32,
Expand All @@ -393,7 +393,7 @@ where

/// Parse the color() function.
#[inline]
fn parse_color_with_color_space<'i, 't, P>(
fn parse_color_with_color_space<'i, P>(
color_parser: &P,
arguments: &mut Parser,
) -> Result<P::Output, ParseError<P::Error>>
Expand Down Expand Up @@ -427,7 +427,7 @@ type ComponentParseResult<R1, R2, R3, Error> =
Result<(Option<R1>, Option<R2>, Option<R3>, Option<f32>), ParseError<Error>>;

/// Parse the color components and alpha with the modern [color-4] syntax.
pub fn parse_components<'i, 't, P, F1, F2, F3, R1, R2, R3>(
pub fn parse_components<'i, P, F1, F2, F3, R1, R2, R3>(
color_parser: &P,
input: &mut Parser,
f1: F1,
Expand Down
11 changes: 3 additions & 8 deletions color/tests.rs
This file contains hidden or 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
Expand Up @@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use super::*;
use cssparser::ParserInput;
use serde_json::{json, Value};

fn almost_equals(a: &Value, b: &Value) -> bool {
Expand Down Expand Up @@ -60,8 +59,7 @@ fn run_raw_json_tests<F: Fn(Value, Value)>(json_data: &str, run: F) {
fn run_json_tests<F: Fn(&mut Parser) -> Value>(json_data: &str, parse: F) {
run_raw_json_tests(json_data, |input, expected| match input {
Value::String(input) => {
let mut parse_input = ParserInput::new(&input);
let result = parse(&mut Parser::new(&mut parse_input));
let result = parse(&mut Parser::new(&input));
assert_json_eq(result, expected, &input);
}
_ => panic!("Unexpected JSON"),
Expand Down Expand Up @@ -149,9 +147,7 @@ fn color4_color_function() {

macro_rules! parse_single_color {
($i:expr) => {{
let input = $i;
let mut input = ParserInput::new(input);
let mut input = Parser::new(&mut input);
let mut input = Parser::new($i);
Color::parse(&mut input).map_err(Into::<ParseError<()>>::into)
}};
}
Expand Down Expand Up @@ -355,8 +351,7 @@ fn generic_parser() {
];

for (input, expected) in TESTS {
let mut input = ParserInput::new(input);
let mut input = Parser::new(&mut input);
let mut input = Parser::new(input);

let actual: OutputType = parse_color_with(&TestColorParser, &mut input).unwrap();
assert_eq!(actual, *expected);
Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL