Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix & ignore new lints #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,8 @@ macro_rules! impl_into_partial_eq_ord {
($wider:ty, $to_wider:expr) => {
impl From<AsciiChar> for $wider {
#[inline]
fn from(a: AsciiChar) -> $wider {
$to_wider(a)
fn from(ascii: AsciiChar) -> $wider {
$to_wider(ascii)
}
}
impl PartialEq<$wider> for AsciiChar {
Expand Down
4 changes: 2 additions & 2 deletions src/ascii_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,12 +1603,12 @@ mod tests {
assert_eq!(asciis.size_hint(), strs.size_hint());
let (a, s) = (asciis.next(), strs.next());
assert_eq!(a, s);
if a == None {
if a.is_none() {
break;
}
}
// test fusedness if str's version is fused
if strs.next() == None {
if strs.next().is_none() {
assert_eq!(asciis.next(), None);
}
}
Expand Down
24 changes: 21 additions & 3 deletions src/ascii_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,14 @@ impl_eq! { AsciiString, &str }
impl Borrow<AsciiStr> for AsciiString {
#[inline]
fn borrow(&self) -> &AsciiStr {
&**self
self
}
}

impl BorrowMut<AsciiStr> for AsciiString {
#[inline]
fn borrow_mut(&mut self) -> &mut AsciiStr {
&mut **self
self
}
}

Expand Down Expand Up @@ -594,7 +594,7 @@ impl<'a> From<&'a AsciiStr> for Cow<'a, AsciiStr> {
impl AsRef<AsciiStr> for AsciiString {
#[inline]
fn as_ref(&self) -> &AsciiStr {
&**self
self
}
}

Expand Down Expand Up @@ -1048,6 +1048,24 @@ mod tests {
assert!(fmt::write(&mut s2, format_args!("{}", sparkle_heart)).is_err());
}

#[test]
fn as_ref() {
let mut s = AsciiString::from_ascii(&[b'a', b'b', b'c'][..]).unwrap();
let as_ref: &AsciiStr = s.as_ref();
assert_eq!(as_ref, AsciiStr::from_ascii_str("abc").unwrap());
let as_mut: &mut AsciiStr = s.as_mut();
assert_eq!(as_mut.len(), s.len());
}

#[test]
fn borrow() {
let mut s = AsciiString::from_ascii(&[b'1', b'2', b'3'][..]).unwrap();
let borrowed: &AsciiStr = &s;
assert_eq!(borrowed, AsciiStr::from_ascii_str("123").unwrap());
let borrowed: &mut AsciiStr = &mut s;
assert_eq!(borrowed.len(), s.len());
}

#[test]
fn to_and_from_box() {
let string = "abc".into_ascii_string().unwrap();
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@
#![allow(clippy::shadow_unrelated, clippy::shadow_reuse, clippy::shadow_same)]
// A `if let` / `else` sometimes looks better than using iterator adaptors
#![allow(clippy::option_if_let_else)]
//
#![allow(clippy::uninlined_format_args)]
// #[default]-on-enum-variant was added in 1.66.0.
#![allow(clippy::derivable_impls)]
// In tests, we're fine with indexing, since a panic is a failure.
#![cfg_attr(test, allow(clippy::indexing_slicing))]
// for compatibility with methods on char and u8
#![allow(clippy::trivially_copy_pass_by_ref)]
// requires 1.65, might not be worth it
#![allow(clippy::manual_let_else)]
// In preparation for feature `unsafe_block_in_unsafe_fn` (https://github.com/rust-lang/rust/issues/71668)
#![allow(unused_unsafe)]

Expand Down