mirror of
https://github.com/ratatui-org/ratatui
synced 2025-02-16 14:08:44 +00:00
chore: add clippy::string_slice
Fixes: https://github.com/ratatui-org/ratatui/issues/1056
This commit is contained in:
parent
4bfdc15b80
commit
9692366d12
3 changed files with 15 additions and 1 deletions
|
@ -99,6 +99,7 @@ string_slice = "warn"
|
|||
string_to_string = "warn"
|
||||
unnecessary_self_imports = "warn"
|
||||
use_self = "warn"
|
||||
string_slice = "warn"
|
||||
|
||||
[features]
|
||||
#! The crate provides a set of optional features that can be enabled in your `cargo.toml` file.
|
||||
|
|
|
@ -313,7 +313,16 @@ impl FromStr for Color {
|
|||
_ => {
|
||||
if let Ok(index) = s.parse::<u8>() {
|
||||
Self::Indexed(index)
|
||||
} else if let Some((r, g, b)) = parse_hex_color(s) {
|
||||
} else if let (Ok(r), Ok(g), Ok(b)) = {
|
||||
if !s.starts_with('#') || s.len() != 7 {
|
||||
return Err(ParseColorError);
|
||||
}
|
||||
(
|
||||
u8::from_str_radix(&s.chars().skip(1).take(2).collect::<String>(), 16),
|
||||
u8::from_str_radix(&s.chars().skip(3).take(2).collect::<String>(), 16),
|
||||
u8::from_str_radix(&s.chars().skip(5).take(2).collect::<String>(), 16),
|
||||
)
|
||||
} {
|
||||
Self::Rgb(r, g, b)
|
||||
} else {
|
||||
return Err(ParseColorError);
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// The code that works on text pays attention to unicode in this file by working in graphemes
|
||||
// instead of byte indexes. This is important for languages that use double-width characters.
|
||||
#![allow(clippy::string_slice)]
|
||||
|
||||
use std::{collections::VecDeque, vec::IntoIter};
|
||||
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
|
Loading…
Add table
Reference in a new issue