1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-03 14:26:17 +03:00
Этот коммит содержится в:
rhysd
2024-12-01 14:04:10 +09:00
родитель 7f2722256d
Коммит ad518def02
4 изменённых файлов: 21 добавлений и 29 удалений

Просмотреть файл

@@ -28,7 +28,7 @@ struct SearchBox<'a> {
open: bool,
}
impl<'a> Default for SearchBox<'a> {
impl Default for SearchBox<'_> {
fn default() -> Self {
let mut textarea = TextArea::default();
textarea.set_block(Block::default().borders(Borders::ALL).title("Search"));
@@ -39,7 +39,7 @@ impl<'a> Default for SearchBox<'a> {
}
}
impl<'a> SearchBox<'a> {
impl SearchBox<'_> {
fn open(&mut self) {
self.open = true;
}
@@ -96,7 +96,7 @@ struct Buffer<'a> {
modified: bool,
}
impl<'a> Buffer<'a> {
impl Buffer<'_> {
fn new(path: PathBuf) -> io::Result<Self> {
let mut textarea = if let Ok(md) = path.metadata() {
if md.is_file() {
@@ -143,7 +143,7 @@ struct Editor<'a> {
search: SearchBox<'a>,
}
impl<'a> Editor<'a> {
impl Editor<'_> {
fn new<I>(paths: I) -> io::Result<Self>
where
I: Iterator,
@@ -348,7 +348,7 @@ impl<'a> Editor<'a> {
}
}
impl<'a> Drop for Editor<'a> {
impl Drop for Editor<'_> {
fn drop(&mut self) {
self.term.show_cursor().unwrap();
disable_raw_mode().unwrap();

Просмотреть файл

@@ -31,7 +31,7 @@ struct SearchBox<'a> {
open: bool,
}
impl<'a> Default for SearchBox<'a> {
impl Default for SearchBox<'_> {
fn default() -> Self {
let mut textarea = TextArea::default();
textarea.set_block(Block::default().borders(Borders::ALL).title("Search"));
@@ -42,7 +42,7 @@ impl<'a> Default for SearchBox<'a> {
}
}
impl<'a> SearchBox<'a> {
impl SearchBox<'_> {
fn open(&mut self) {
self.open = true;
}
@@ -99,7 +99,7 @@ struct Buffer<'a> {
modified: bool,
}
impl<'a> Buffer<'a> {
impl Buffer<'_> {
fn new(path: PathBuf) -> io::Result<Self> {
let mut textarea = if let Ok(md) = path.metadata() {
if md.is_file() {
@@ -146,7 +146,7 @@ struct Editor<'a> {
search: SearchBox<'a>,
}
impl<'a> Editor<'a> {
impl Editor<'_> {
fn new<I>(paths: I) -> io::Result<Self>
where
I: Iterator,
@@ -351,7 +351,7 @@ impl<'a> Editor<'a> {
}
}
impl<'a> Drop for Editor<'a> {
impl Drop for Editor<'_> {
fn drop(&mut self) {
self.term.show_cursor().unwrap();
disable_raw_mode().unwrap();

Просмотреть файл

@@ -147,7 +147,7 @@ pub struct TextArea<'a> {
/// let textarea = TextArea::from(slice.iter().copied());
/// assert_eq!(textarea.lines(), ["hello", "world"]);
/// ```
impl<'a, I> From<I> for TextArea<'a>
impl<I> From<I> for TextArea<'_>
where
I: IntoIterator,
I::Item: Into<String>,
@@ -174,7 +174,7 @@ where
/// let textarea = read_from_file("README.md").unwrap();
/// assert!(!textarea.is_empty());
/// ```
impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> {
impl<S: Into<String>> FromIterator<S> for TextArea<'_> {
fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self {
iter.into()
}
@@ -188,7 +188,7 @@ impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> {
/// assert_eq!(textarea.lines(), [""]);
/// assert!(textarea.is_empty());
/// ```
impl<'a> Default for TextArea<'a> {
impl Default for TextArea<'_> {
fn default() -> Self {
Self::new(vec![String::new()])
}

Просмотреть файл

@@ -110,10 +110,8 @@ fn back() {
#[test]
fn up() {
for text in [
["abc", "def", "ghi"],
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"],
] {
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"]]
{
let mut t = TextArea::from(text);
for col in 0..=3 {
@@ -146,10 +144,8 @@ fn up_trim() {
#[test]
fn down() {
for text in [
["abc", "def", "ghi"],
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"],
] {
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"]]
{
let mut t = TextArea::from(text);
for col in 0..=3 {
@@ -217,10 +213,8 @@ fn end() {
#[test]
fn top() {
for text in [
["abc", "def", "ghi"],
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"],
] {
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"]]
{
let mut t = TextArea::from(text);
for row in 0..=2 {
for col in 0..=3 {
@@ -250,10 +244,8 @@ fn top_trim() {
#[test]
fn bottom() {
for text in [
["abc", "def", "ghi"],
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"],
] {
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻‍❤️‍💋‍👨🏾"]]
{
let mut t = TextArea::from(text);
for row in 0..=2 {
for col in 0..=3 {