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