mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Fix clippy warnings
This commit is contained in:
parent
da8310b076
commit
5dfdeab6ae
@ -15,7 +15,7 @@ fn main() {
|
||||
styled.append(StyledString::styled("that ", Color::Dark(BaseColor::Red)));
|
||||
styled.append(StyledString::styled(
|
||||
"cool?",
|
||||
Style::from(Color::Light(BaseColor::Blue)).add(Effect::Bold),
|
||||
Style::from(Color::Light(BaseColor::Blue)).combine(Effect::Bold),
|
||||
));
|
||||
|
||||
// TextView can natively accept StyledString.
|
||||
|
@ -383,7 +383,7 @@ impl Cursive {
|
||||
{
|
||||
self.global_callbacks
|
||||
.entry(event.into())
|
||||
.or_insert(Vec::new())
|
||||
.or_insert_with(Vec::new)
|
||||
.push(Callback::from_fn(cb));
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ pub(crate) fn load_table(palette: &mut Palette, table: &toml::value::Table) {
|
||||
|
||||
/// Color entry in a palette.
|
||||
///
|
||||
/// Each ColorRole is used for a specific role in a default application.
|
||||
/// Each `ColorRole` is used for a specific role in a default application.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, EnumMap)]
|
||||
pub enum PaletteColor {
|
||||
/// Color used for the application background.
|
||||
|
@ -51,7 +51,7 @@ impl Style {
|
||||
}
|
||||
|
||||
/// Returns a combination of `self` and `other`.
|
||||
pub fn add<S>(self, other: S) -> Self
|
||||
pub fn combine<S>(self, other: S) -> Self
|
||||
where
|
||||
S: Into<Style>,
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ impl<T> SpannedString<T> {
|
||||
// Make sure the spans are within bounds.
|
||||
// This should disapear when compiled in release mode.
|
||||
for span in &spans {
|
||||
if let IndexedCow::Borrowed { start: _, end } = span.content {
|
||||
if let IndexedCow::Borrowed { end, .. } = span.content {
|
||||
assert!(end <= source.len());
|
||||
}
|
||||
}
|
||||
@ -66,14 +66,14 @@ impl<T> SpannedString<T> {
|
||||
S: Into<Self>,
|
||||
{
|
||||
let other = other.into();
|
||||
self.append_raw(other.source, other.spans);
|
||||
self.append_raw(&other.source, other.spans);
|
||||
}
|
||||
|
||||
/// Appends `content` and its corresponding spans to the end.
|
||||
///
|
||||
/// It is not recommended to use this directly;
|
||||
/// instead, look at the `append` method.
|
||||
pub fn append_raw(&mut self, source: String, spans: Vec<IndexedSpan<T>>) {
|
||||
pub fn append_raw(&mut self, source: &str, spans: Vec<IndexedSpan<T>>) {
|
||||
let offset = self.source.len();
|
||||
let mut spans = spans;
|
||||
|
||||
@ -170,7 +170,7 @@ impl IndexedCow {
|
||||
pub fn resolve<'a>(&'a self, source: &'a str) -> &'a str {
|
||||
match *self {
|
||||
IndexedCow::Borrowed { start, end } => &source[start..end],
|
||||
IndexedCow::Owned(ref content) => &content,
|
||||
IndexedCow::Owned(ref content) => content,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ impl Dialog {
|
||||
let width = self.buttons
|
||||
.iter()
|
||||
.map(|button| button.button.size.x)
|
||||
.fold(0, |a, b| a + b)
|
||||
.sum::<usize>()
|
||||
+ self.buttons.len().saturating_sub(1);
|
||||
let overhead = self.padding + self.borders;
|
||||
if printer.size.x < overhead.horizontal() {
|
||||
|
@ -477,7 +477,7 @@ impl View for EditView {
|
||||
}
|
||||
})
|
||||
.map(|g| g.len())
|
||||
.fold(0, |a, b| a + b);
|
||||
.sum();
|
||||
|
||||
let content = &content[..display_bytes];
|
||||
let width = content.width();
|
||||
|
@ -117,9 +117,9 @@ impl TextContent {
|
||||
}
|
||||
}
|
||||
|
||||
/// Internel representation of the content for a TextView.
|
||||
/// Internel representation of the content for a `TextView`.
|
||||
///
|
||||
/// This is mostly just a StyledString.
|
||||
/// This is mostly just a `StyledString`.
|
||||
///
|
||||
/// Can be shared (through a `Arc<Mutex>`).
|
||||
struct TextContentInner {
|
||||
@ -463,7 +463,7 @@ impl View for TextView {
|
||||
|
||||
for span in row.resolve(&content.content) {
|
||||
printer.with_style(*span.attr, |printer| {
|
||||
printer.print((x, 0), &span.content);
|
||||
printer.print((x, 0), span.content);
|
||||
x += span.content.width();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user