Skip to content

Commit

Permalink
const ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 6, 2024
1 parent bf7be71 commit d4984b5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> Attribute<'a> {
/// Creates a borrowed attribute using the provided borrowed name and a borrowed string value.
#[inline]
#[must_use]
pub fn new(name: Name<'a>, value: &'a str) -> Attribute<'a> {
pub const fn new(name: Name<'a>, value: &'a str) -> Self {
Attribute { name, value }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! gen_setter {
/// <small>See [`ParserConfig`][crate::ParserConfig] fields docs for details</small>
#[inline]
#[must_use]
pub fn $field(mut self, value: $t) -> Self {
pub const fn $field(mut self, value: $t) -> Self {
self.$field = value;
self
}
Expand All @@ -32,7 +32,7 @@ macro_rules! gen_setter {
/// <small>See [`ParserConfig`][crate::ParserConfig] fields docs for details</small>
#[inline]
#[must_use]
pub fn $field(mut self, value: $t) -> Self {
pub const fn $field(mut self, value: $t) -> Self {
self.c.$field = value;
self
}
Expand Down
8 changes: 4 additions & 4 deletions src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> Name<'a> {
/// Returns a new `Name` instance representing plain local name.
#[inline]
#[must_use]
pub fn local(local_name: &str) -> Name<'_> {
pub const fn local(local_name: &str) -> Name<'_> {
Name {
local_name,
prefix: None,
Expand All @@ -110,7 +110,7 @@ impl<'a> Name<'a> {
/// Returns a new `Name` instance with the given local name and prefix.
#[inline]
#[must_use]
pub fn prefixed(local_name: &'a str, prefix: &'a str) -> Name<'a> {
pub const fn prefixed(local_name: &'a str, prefix: &'a str) -> Self {
Name {
local_name,
namespace: None,
Expand All @@ -122,7 +122,7 @@ impl<'a> Name<'a> {
/// with a namespace URI.
#[inline]
#[must_use]
pub fn qualified(local_name: &'a str, namespace: &'a str, prefix: Option<&'a str>) -> Name<'a> {
pub const fn qualified(local_name: &'a str, namespace: &'a str, prefix: Option<&'a str>) -> Self {
Name {
local_name,
namespace: Some(namespace),
Expand All @@ -146,7 +146,7 @@ impl<'a> Name<'a> {
/// allocations.
#[inline]
#[must_use]
pub fn repr_display(&self) -> ReprDisplay<'_, '_> {
pub const fn repr_display(&self) -> ReprDisplay<'_, '_> {
ReprDisplay(self)
}

Expand Down
10 changes: 5 additions & 5 deletions src/writer/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a> XmlEvent<'a> {
/// Returns an writer event for a processing instruction.
#[inline]
#[must_use]
pub fn processing_instruction(name: &'a str, data: Option<&'a str>) -> XmlEvent<'a> {
pub const fn processing_instruction(name: &'a str, data: Option<&'a str>) -> Self {
XmlEvent::ProcessingInstruction { name, data }
}

Expand All @@ -121,7 +121,7 @@ impl<'a> XmlEvent<'a> {
/// is disabled, it is possible to specify the name with `name()` method on the builder.
#[inline]
#[must_use]
pub fn end_element() -> EndElementBuilder<'a> {
pub const fn end_element() -> EndElementBuilder<'a> {
EndElementBuilder { name: None }
}

Expand All @@ -131,7 +131,7 @@ impl<'a> XmlEvent<'a> {
/// (depending on the configuration).
#[inline]
#[must_use]
pub fn cdata(data: &'a str) -> XmlEvent<'a> {
pub const fn cdata(data: &'a str) -> Self {
XmlEvent::CData(data)
}

Expand All @@ -140,14 +140,14 @@ impl<'a> XmlEvent<'a> {
/// All offending symbols, in particular, `&` and `<`, will be escaped by the writer.
#[inline]
#[must_use]
pub fn characters(data: &'a str) -> XmlEvent<'a> {
pub const fn characters(data: &'a str) -> Self {
XmlEvent::Characters(data)
}

/// Returns a comment event.
#[inline]
#[must_use]
pub fn comment(data: &'a str) -> XmlEvent<'a> {
pub const fn comment(data: &'a str) -> Self {
XmlEvent::Comment(data)
}
}
Expand Down

0 comments on commit d4984b5

Please sign in to comment.