Skip to content

Commit

Permalink
Drop const from places where it was previously added
Browse files Browse the repository at this point in the history
It makes the MSRV overly restrictive, and doesn't provide much benefit.
  • Loading branch information
dralley committed Sep 18, 2022
1 parent b96954b commit a0317de
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Expand Up @@ -16,6 +16,11 @@

### Misc Changes

- [#481]: Removed the uses of `const fn` added in version 0.24 in favor of a lower minimum
supported Rust version. Minimum supported Rust version is now tested in the CI.

[#481]: https://github.com/tafia/quick-xml/pull/481

## 0.25.0 -- 2022-09-10

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion src/de/escape.rs
Expand Up @@ -25,7 +25,7 @@ pub struct EscapedDeserializer<'a> {
}

impl<'a> EscapedDeserializer<'a> {
pub const fn new(escaped_value: Cow<'a, [u8]>, decoder: Decoder, escaped: bool) -> Self {
pub fn new(escaped_value: Cow<'a, [u8]>, decoder: Decoder, escaped: bool) -> Self {
EscapedDeserializer {
decoder,
escaped_value,
Expand Down
2 changes: 1 addition & 1 deletion src/de/simple_type.rs
Expand Up @@ -546,7 +546,7 @@ impl<'de, 'a> SimpleTypeDeserializer<'de, 'a> {

/// Constructor for tests
#[inline]
const fn new(content: CowRef<'de, 'a>, escaped: bool, decoder: Decoder) -> Self {
fn new(content: CowRef<'de, 'a>, escaped: bool, decoder: Decoder) -> Self {
Self {
content,
escaped,
Expand Down
2 changes: 1 addition & 1 deletion src/encoding.rs
Expand Up @@ -61,7 +61,7 @@ impl Decoder {
///
/// [`decode`]: Self::decode
#[cfg(feature = "encoding")]
pub const fn encoding(&self) -> &'static Encoding {
pub fn encoding(&self) -> &'static Encoding {
self.encoding
}

Expand Down
12 changes: 6 additions & 6 deletions src/events/attributes.rs
Expand Up @@ -191,20 +191,20 @@ pub struct Attributes<'a> {
impl<'a> Attributes<'a> {
/// Internal constructor, used by `BytesStart`. Supplies data in reader's encoding
#[inline]
pub(crate) const fn wrap(buf: &'a [u8], pos: usize, html: bool) -> Self {
pub(crate) fn wrap(buf: &'a [u8], pos: usize, html: bool) -> Self {
Self {
bytes: buf,
state: IterState::new(pos, html),
}
}

/// Creates a new attribute iterator from a buffer.
pub const fn new(buf: &'a str, pos: usize) -> Self {
pub fn new(buf: &'a str, pos: usize) -> Self {
Self::wrap(buf.as_bytes(), pos, false)
}

/// Creates a new attribute iterator from a buffer, allowing HTML attribute syntax.
pub const fn html(buf: &'a str, pos: usize) -> Self {
pub fn html(buf: &'a str, pos: usize) -> Self {
Self::wrap(buf.as_bytes(), pos, true)
}

Expand Down Expand Up @@ -412,7 +412,7 @@ impl<T> Attr<T> {
impl<'a> Attr<&'a [u8]> {
/// Returns the key value
#[inline]
pub const fn key(&self) -> QName<'a> {
pub fn key(&self) -> QName<'a> {
QName(match self {
Attr::DoubleQ(key, _) => key,
Attr::SingleQ(key, _) => key,
Expand All @@ -425,7 +425,7 @@ impl<'a> Attr<&'a [u8]> {
///
/// [HTML specification]: https://www.w3.org/TR/2012/WD-html-markup-20120329/syntax.html#syntax-attr-empty
#[inline]
pub const fn value(&self) -> &'a [u8] {
pub fn value(&self) -> &'a [u8] {
match self {
Attr::DoubleQ(_, value) => value,
Attr::SingleQ(_, value) => value,
Expand Down Expand Up @@ -514,7 +514,7 @@ pub(crate) struct IterState {
}

impl IterState {
pub const fn new(offset: usize, html: bool) -> Self {
pub fn new(offset: usize, html: bool) -> Self {
Self {
state: State::Next(offset),
html,
Expand Down
6 changes: 3 additions & 3 deletions src/events/mod.rs
Expand Up @@ -72,7 +72,7 @@ pub struct BytesStart<'a> {
impl<'a> BytesStart<'a> {
/// Internal constructor, used by `Reader`. Supplies data in reader's encoding
#[inline]
pub(crate) const fn wrap(content: &'a [u8], name_len: usize) -> Self {
pub(crate) fn wrap(content: &'a [u8], name_len: usize) -> Self {
BytesStart {
buf: Cow::Borrowed(content),
name_len,
Expand Down Expand Up @@ -344,7 +344,7 @@ impl<'a> BytesDecl<'a> {
}

/// Creates a `BytesDecl` from a `BytesStart`
pub const fn from_start(start: BytesStart<'a>) -> Self {
pub fn from_start(start: BytesStart<'a>) -> Self {
Self { content: start }
}

Expand Down Expand Up @@ -549,7 +549,7 @@ pub struct BytesEnd<'a> {
impl<'a> BytesEnd<'a> {
/// Internal constructor, used by `Reader`. Supplies data in reader's encoding
#[inline]
pub(crate) const fn wrap(name: Cow<'a, [u8]>) -> Self {
pub(crate) fn wrap(name: Cow<'a, [u8]>) -> Self {
BytesEnd { name }
}

Expand Down
8 changes: 4 additions & 4 deletions src/name.rs
Expand Up @@ -21,7 +21,7 @@ pub struct QName<'a>(pub &'a [u8]);
impl<'a> QName<'a> {
/// Converts this name to an internal slice representation.
#[inline(always)]
pub const fn into_inner(self) -> &'a [u8] {
pub fn into_inner(self) -> &'a [u8] {
self.0
}

Expand Down Expand Up @@ -138,7 +138,7 @@ pub struct LocalName<'a>(&'a [u8]);
impl<'a> LocalName<'a> {
/// Converts this name to an internal slice representation.
#[inline(always)]
pub const fn into_inner(self) -> &'a [u8] {
pub fn into_inner(self) -> &'a [u8] {
self.0
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ pub struct Prefix<'a>(&'a [u8]);
impl<'a> Prefix<'a> {
/// Extracts internal slice
#[inline(always)]
pub const fn into_inner(self) -> &'a [u8] {
pub fn into_inner(self) -> &'a [u8] {
self.0
}
}
Expand Down Expand Up @@ -253,7 +253,7 @@ impl<'a> Namespace<'a> {
/// [non-normalized]: https://www.w3.org/TR/REC-xml/#AVNormalize
/// [IRI reference]: https://datatracker.ietf.org/doc/html/rfc3987
#[inline(always)]
pub const fn into_inner(self) -> &'a [u8] {
pub fn into_inner(self) -> &'a [u8] {
self.0
}
//TODO: implement value normalization and use it when comparing namespaces
Expand Down
12 changes: 6 additions & 6 deletions src/reader/mod.rs
Expand Up @@ -377,7 +377,7 @@ enum EncodingRef {
#[cfg(feature = "encoding")]
impl EncodingRef {
#[inline]
const fn encoding(&self) -> &'static Encoding {
fn encoding(&self) -> &'static Encoding {
match self {
Self::Implicit(e) => e,
Self::Explicit(e) => e,
Expand All @@ -386,7 +386,7 @@ impl EncodingRef {
}
}
#[inline]
const fn can_be_refined(&self) -> bool {
fn can_be_refined(&self) -> bool {
match self {
Self::Implicit(_) | Self::BomDetected(_) => true,
Self::Explicit(_) | Self::XmlDetected(_) => false,
Expand Down Expand Up @@ -531,7 +531,7 @@ impl<R> Reader<R> {
}

/// Gets a reference to the underlying reader.
pub const fn get_ref(&self) -> &R {
pub fn get_ref(&self) -> &R {
&self.reader
}

Expand All @@ -543,7 +543,7 @@ impl<R> Reader<R> {
/// Gets the current byte position in the input data.
///
/// Useful when debugging errors.
pub const fn buffer_position(&self) -> usize {
pub fn buffer_position(&self) -> usize {
// when internal state is OpenedTag, we have actually read until '<',
// which we don't want to show
if let ParseState::OpenedTag = self.parser.state {
Expand All @@ -561,7 +561,7 @@ impl<R> Reader<R> {
/// If `encoding` feature is enabled and no encoding is specified in declaration,
/// defaults to UTF-8.
#[inline]
pub const fn decoder(&self) -> Decoder {
pub fn decoder(&self) -> Decoder {
self.parser.decoder()
}
}
Expand Down Expand Up @@ -848,7 +848,7 @@ impl ReadElementState {

/// A function to check whether the byte is a whitespace (blank, new line, carriage return or tab)
#[inline]
pub(crate) const fn is_whitespace(b: u8) -> bool {
pub(crate) fn is_whitespace(b: u8) -> bool {
match b {
b' ' | b'\r' | b'\n' | b'\t' => true,
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion src/reader/parser.rs
Expand Up @@ -236,7 +236,7 @@ impl Parser {
///
/// If `encoding` feature is enabled and no encoding is specified in declaration,
/// defaults to UTF-8.
pub const fn decoder(&self) -> Decoder {
pub fn decoder(&self) -> Decoder {
Decoder {
#[cfg(feature = "encoding")]
encoding: self.encoding.encoding(),
Expand Down
2 changes: 1 addition & 1 deletion src/reader/slice_reader.rs
Expand Up @@ -353,7 +353,7 @@ mod test {
use crate::reader::XmlSource;

/// Default buffer constructor just pass the byte array from the test
const fn identity<T>(input: T) -> T {
fn identity<T>(input: T) -> T {
input
}

Expand Down
4 changes: 2 additions & 2 deletions src/se/mod.rs
Expand Up @@ -117,7 +117,7 @@ impl<'r, W: Write> Serializer<'r, W> {
/// Note, that attempt to serialize a non-struct (including unit structs
/// and newtype structs) will end up to an error. Use `with_root` to create
/// serializer with explicitly defined root element name
pub const fn new(writer: W) -> Self {
pub fn new(writer: W) -> Self {
Self::with_root(Writer::new(writer), None)
}

Expand Down Expand Up @@ -169,7 +169,7 @@ impl<'r, W: Write> Serializer<'r, W> {
/// r#"<root question="The Ultimate Question of Life, the Universe, and Everything" answer="42"/>"#
/// );
/// ```
pub const fn with_root(writer: Writer<W>, root_tag: Option<&'r str>) -> Self {
pub fn with_root(writer: Writer<W>, root_tag: Option<&'r str>) -> Self {
Self { writer, root_tag }
}

Expand Down
2 changes: 1 addition & 1 deletion src/writer.rs
Expand Up @@ -61,7 +61,7 @@ pub struct Writer<W: Write> {

impl<W: Write> Writer<W> {
/// Creates a `Writer` from a generic writer.
pub const fn new(inner: W) -> Writer<W> {
pub fn new(inner: W) -> Writer<W> {
Writer {
writer: inner,
indent: None,
Expand Down

0 comments on commit a0317de

Please sign in to comment.