Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions color/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ pub struct Hsl {

impl Hsl {
/// Construct a new HSL color from it's components.
pub fn new(
pub const fn new(
hue: Option<f32>,
saturation: Option<f32>,
lightness: Option<f32>,
Expand Down Expand Up @@ -619,7 +619,7 @@ pub struct Hwb {

impl Hwb {
/// Construct a new HWB color from it's components.
pub fn new(
pub const fn new(
hue: Option<f32>,
whiteness: Option<f32>,
blackness: Option<f32>,
Expand Down Expand Up @@ -685,7 +685,7 @@ macro_rules! impl_lab_like {
($cls:ident, $fname:literal) => {
impl $cls {
/// Construct a new Lab color format with lightness, a, b and alpha components.
pub fn new(
pub const fn new(
lightness: Option<f32>,
a: Option<f32>,
b: Option<f32>,
Expand Down Expand Up @@ -757,7 +757,7 @@ macro_rules! impl_lch_like {
($cls:ident, $fname:literal) => {
impl $cls {
/// Construct a new color with lightness, chroma and hue components.
pub fn new(
pub const fn new(
lightness: Option<f32>,
chroma: Option<f32>,
hue: Option<f32>,
Expand Down Expand Up @@ -814,7 +814,7 @@ pub struct ColorFunction {
impl ColorFunction {
/// Construct a new color function definition with the given color space and
/// color components.
pub fn new(
pub const fn new(
color_space: PredefinedColorSpace,
c1: Option<f32>,
c2: Option<f32>,
Expand Down
22 changes: 11 additions & 11 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ impl<'i, T> From<BasicParseError<'i>> for ParseError<'i, T> {
impl SourceLocation {
/// Create a new BasicParseError at this location for an unexpected token
#[inline]
pub fn new_basic_unexpected_token_error(self, token: Token<'_>) -> BasicParseError<'_> {
pub const fn new_basic_unexpected_token_error(self, token: Token<'_>) -> BasicParseError<'_> {
self.new_basic_error(BasicParseErrorKind::UnexpectedToken(token))
}

/// Create a new BasicParseError at this location
#[inline]
pub fn new_basic_error(self, kind: BasicParseErrorKind<'_>) -> BasicParseError<'_> {
pub const fn new_basic_error(self, kind: BasicParseErrorKind<'_>) -> BasicParseError<'_> {
BasicParseError {
kind,
location: self,
Expand All @@ -131,13 +131,13 @@ impl SourceLocation {

/// Create a new ParseError at this location for an unexpected token
#[inline]
pub fn new_unexpected_token_error<E>(self, token: Token<'_>) -> ParseError<'_, E> {
pub const fn new_unexpected_token_error<E>(self, token: Token<'_>) -> ParseError<'_, E> {
self.new_error(BasicParseErrorKind::UnexpectedToken(token))
}

/// Create a new basic ParseError at the current location
#[inline]
pub fn new_error<E>(self, kind: BasicParseErrorKind<'_>) -> ParseError<'_, E> {
pub const fn new_error<E>(self, kind: BasicParseErrorKind<'_>) -> ParseError<'_, E> {
ParseError {
kind: ParseErrorKind::Basic(kind),
location: self,
Expand Down Expand Up @@ -240,7 +240,7 @@ struct CachedToken<'i> {

impl<'i> ParserInput<'i> {
/// Create a new input for a parser.
pub fn new(input: &'i str) -> ParserInput<'i> {
pub const fn new(input: &'i str) -> ParserInput<'i> {
ParserInput {
tokenizer: Tokenizer::new(input),
cached_token: None,
Expand Down Expand Up @@ -383,7 +383,7 @@ macro_rules! expect {
impl<'i: 't, 't> Parser<'i, 't> {
/// Create a new parser
#[inline]
pub fn new(input: &'t mut ParserInput<'i>) -> Parser<'i, 't> {
pub const fn new(input: &'t mut ParserInput<'i>) -> Parser<'i, 't> {
Parser {
input,
at_start_of: None,
Expand Down Expand Up @@ -435,7 +435,7 @@ impl<'i: 't, 't> Parser<'i, 't> {

/// The current line number and column number.
#[inline]
pub fn current_source_location(&self) -> SourceLocation {
pub const fn current_source_location(&self) -> SourceLocation {
self.input.tokenizer.current_source_location()
}

Expand All @@ -459,13 +459,13 @@ impl<'i: 't, 't> Parser<'i, 't> {

/// Create a new BasicParseError at the current location
#[inline]
pub fn new_basic_error(&self, kind: BasicParseErrorKind<'i>) -> BasicParseError<'i> {
pub const fn new_basic_error(&self, kind: BasicParseErrorKind<'i>) -> BasicParseError<'i> {
self.current_source_location().new_basic_error(kind)
}

/// Create a new basic ParseError at the current location
#[inline]
pub fn new_error<E>(&self, kind: BasicParseErrorKind<'i>) -> ParseError<'i, E> {
pub const fn new_error<E>(&self, kind: BasicParseErrorKind<'i>) -> ParseError<'i, E> {
self.current_source_location().new_error(kind)
}

Expand All @@ -477,13 +477,13 @@ impl<'i: 't, 't> Parser<'i, 't> {

/// Create a new unexpected token BasicParseError at the current location
#[inline]
pub fn new_basic_unexpected_token_error(&self, token: Token<'i>) -> BasicParseError<'i> {
pub const fn new_basic_unexpected_token_error(&self, token: Token<'i>) -> BasicParseError<'i> {
self.new_basic_error(BasicParseErrorKind::UnexpectedToken(token))
}

/// Create a new unexpected token ParseError at the current location
#[inline]
pub fn new_unexpected_token_error<E>(&self, token: Token<'i>) -> ParseError<'i, E> {
pub const fn new_unexpected_token_error<E>(&self, token: Token<'i>) -> ParseError<'i, E> {
self.new_error(BasicParseErrorKind::UnexpectedToken(token))
}

Expand Down
4 changes: 2 additions & 2 deletions src/rules_and_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<'i, 't, 'a, P, I, E> RuleBodyParser<'i, 't, 'a, P, I, E> {
/// The return type for finished declarations and at-rules also needs to be the same,
/// since `<DeclarationListParser as Iterator>::next` can return either.
/// It could be a custom enum.
pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
pub const fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
Self {
input,
parser,
Expand Down Expand Up @@ -340,7 +340,7 @@ where
///
/// The return type for finished qualified rules and at-rules also needs to be the same,
/// since `<RuleListParser as Iterator>::next` can return either. It could be a custom enum.
pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
pub const fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self {
Self {
input,
parser,
Expand Down
2 changes: 1 addition & 1 deletion src/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ where
W: fmt::Write,
{
/// Wrap a text writer to create a `CssStringWriter`.
pub fn new(inner: &'a mut W) -> CssStringWriter<'a, W> {
pub const fn new(inner: &'a mut W) -> CssStringWriter<'a, W> {
CssStringWriter { inner }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ enum SeenStatus {

impl<'a> Tokenizer<'a> {
#[inline]
pub fn new(input: &'a str) -> Self {
pub const fn new(input: &'a str) -> Self {
Tokenizer {
input,
position: 0,
Expand Down Expand Up @@ -274,7 +274,7 @@ impl<'a> Tokenizer<'a> {
}

#[inline]
pub fn current_source_location(&self) -> SourceLocation {
pub const fn current_source_location(&self) -> SourceLocation {
SourceLocation {
line: self.current_line_number,
column: (self.position - self.current_line_start_position + 1) as u32,
Expand Down
Loading