restrict clippy::string_slice

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-08 16:30:59 +00:00
parent 51df946911
commit 59d86d3641
5 changed files with 7 additions and 2 deletions

View file

@ -790,6 +790,7 @@ rest_pat_in_fully_bound_structs = "warn"
semicolon_outside_block = "warn"
str_to_string = "warn"
string_lit_chars_any = "warn"
string_slice = "warn"
string_to_string = "warn"
suspicious_xor_used_as_pow = "warn"
tests_outside_test_module = "warn"

View file

@ -127,6 +127,7 @@ impl WildCardedDomain {
impl std::str::FromStr for WildCardedDomain {
type Err = std::convert::Infallible;
#[allow(clippy::string_slice)]
fn from_str(s: &str) -> Result<Self, Self::Err> {
// maybe do some domain validation?
Ok(if s.starts_with("*.") {

View file

@ -6,6 +6,7 @@ pub struct Escape<'a>(pub &'a str);
/// Copied from librustdoc:
/// * <https://github.com/rust-lang/rust/blob/cbaeec14f90b59a91a6b0f17fc046c66fa811892/src/librustdoc/html/escape.rs>
#[allow(clippy::string_slice)]
impl fmt::Display for Escape<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
// Because the internet is always right, turns out there's not that many

View file

@ -9,12 +9,13 @@ pub const EMPTY: &str = "";
/// common_prefix(&input) == "con";
/// ```
#[must_use]
#[allow(clippy::string_slice)]
pub fn common_prefix<'a>(choice: &'a [&str]) -> &'a str {
choice.first().map_or(EMPTY, move |best| {
choice.iter().skip(1).fold(*best, |best, choice| {
&best[0..choice
.chars()
.zip(best.chars())
.char_indices()
.zip(best.char_indices())
.take_while(|&(a, b)| a == b)
.count()]
})

View file

@ -484,6 +484,7 @@ impl FedDest {
}
#[inline]
#[allow(clippy::string_slice)]
fn port(&self) -> Option<u16> {
match &self {
Self::Literal(addr) => Some(addr.port()),