Skip to content
Snippets Groups Projects
Commit 59d86d36 authored by Jason Volk's avatar Jason Volk
Browse files

restrict clippy::string_slice


Signed-off-by: default avatarJason Volk <jason@zemos.net>
parent 51df9469
No related branches found
No related tags found
1 merge request!513Maintenance/Fixes
......@@ -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"
......
......@@ -127,6 +127,7 @@ fn more_specific_than(&self, other: &Self) -> bool {
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("*.") {
......
......@@ -6,6 +6,7 @@
/// 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
......
......@@ -9,12 +9,13 @@
/// 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()]
})
......
......@@ -484,6 +484,7 @@ fn hostname(&self) -> String {
}
#[inline]
#[allow(clippy::string_slice)]
fn port(&self) -> Option<u16> {
match &self {
Self::Literal(addr) => Some(addr.port()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment