зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-08 00:15:50 +03:00
prefer eliding lifetimes
Этот коммит содержится в:
@@ -28,7 +28,7 @@ struct SearchBox<'a> {
|
|||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for SearchBox<'a> {
|
impl Default for SearchBox<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let mut textarea = TextArea::default();
|
let mut textarea = TextArea::default();
|
||||||
textarea.set_block(Block::default().borders(Borders::ALL).title("Search"));
|
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) {
|
fn open(&mut self) {
|
||||||
self.open = true;
|
self.open = true;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ struct Buffer<'a> {
|
|||||||
modified: bool,
|
modified: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Buffer<'a> {
|
impl Buffer<'_> {
|
||||||
fn new(path: PathBuf) -> io::Result<Self> {
|
fn new(path: PathBuf) -> io::Result<Self> {
|
||||||
let mut textarea = if let Ok(md) = path.metadata() {
|
let mut textarea = if let Ok(md) = path.metadata() {
|
||||||
if md.is_file() {
|
if md.is_file() {
|
||||||
@@ -143,7 +143,7 @@ struct Editor<'a> {
|
|||||||
search: SearchBox<'a>,
|
search: SearchBox<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Editor<'a> {
|
impl Editor<'_> {
|
||||||
fn new<I>(paths: I) -> io::Result<Self>
|
fn new<I>(paths: I) -> io::Result<Self>
|
||||||
where
|
where
|
||||||
I: Iterator,
|
I: Iterator,
|
||||||
@@ -348,7 +348,7 @@ impl<'a> Editor<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for Editor<'a> {
|
impl Drop for Editor<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.term.show_cursor().unwrap();
|
self.term.show_cursor().unwrap();
|
||||||
disable_raw_mode().unwrap();
|
disable_raw_mode().unwrap();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct SearchBox<'a> {
|
|||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for SearchBox<'a> {
|
impl Default for SearchBox<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let mut textarea = TextArea::default();
|
let mut textarea = TextArea::default();
|
||||||
textarea.set_block(Block::default().borders(Borders::ALL).title("Search"));
|
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) {
|
fn open(&mut self) {
|
||||||
self.open = true;
|
self.open = true;
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ struct Buffer<'a> {
|
|||||||
modified: bool,
|
modified: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Buffer<'a> {
|
impl Buffer<'_> {
|
||||||
fn new(path: PathBuf) -> io::Result<Self> {
|
fn new(path: PathBuf) -> io::Result<Self> {
|
||||||
let mut textarea = if let Ok(md) = path.metadata() {
|
let mut textarea = if let Ok(md) = path.metadata() {
|
||||||
if md.is_file() {
|
if md.is_file() {
|
||||||
@@ -146,7 +146,7 @@ struct Editor<'a> {
|
|||||||
search: SearchBox<'a>,
|
search: SearchBox<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Editor<'a> {
|
impl Editor<'_> {
|
||||||
fn new<I>(paths: I) -> io::Result<Self>
|
fn new<I>(paths: I) -> io::Result<Self>
|
||||||
where
|
where
|
||||||
I: Iterator,
|
I: Iterator,
|
||||||
@@ -351,7 +351,7 @@ impl<'a> Editor<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for Editor<'a> {
|
impl Drop for Editor<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.term.show_cursor().unwrap();
|
self.term.show_cursor().unwrap();
|
||||||
disable_raw_mode().unwrap();
|
disable_raw_mode().unwrap();
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ pub struct TextArea<'a> {
|
|||||||
/// let textarea = TextArea::from(slice.iter().copied());
|
/// let textarea = TextArea::from(slice.iter().copied());
|
||||||
/// assert_eq!(textarea.lines(), ["hello", "world"]);
|
/// assert_eq!(textarea.lines(), ["hello", "world"]);
|
||||||
/// ```
|
/// ```
|
||||||
impl<'a, I> From<I> for TextArea<'a>
|
impl<I> From<I> for TextArea<'_>
|
||||||
where
|
where
|
||||||
I: IntoIterator,
|
I: IntoIterator,
|
||||||
I::Item: Into<String>,
|
I::Item: Into<String>,
|
||||||
@@ -174,7 +174,7 @@ where
|
|||||||
/// let textarea = read_from_file("README.md").unwrap();
|
/// let textarea = read_from_file("README.md").unwrap();
|
||||||
/// assert!(!textarea.is_empty());
|
/// 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 {
|
fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self {
|
||||||
iter.into()
|
iter.into()
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> {
|
|||||||
/// assert_eq!(textarea.lines(), [""]);
|
/// assert_eq!(textarea.lines(), [""]);
|
||||||
/// assert!(textarea.is_empty());
|
/// assert!(textarea.is_empty());
|
||||||
/// ```
|
/// ```
|
||||||
impl<'a> Default for TextArea<'a> {
|
impl Default for TextArea<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new(vec![String::new()])
|
Self::new(vec![String::new()])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,10 +110,8 @@ fn back() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn up() {
|
fn up() {
|
||||||
for text in [
|
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"]]
|
||||||
["abc", "def", "ghi"],
|
{
|
||||||
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"],
|
|
||||||
] {
|
|
||||||
let mut t = TextArea::from(text);
|
let mut t = TextArea::from(text);
|
||||||
|
|
||||||
for col in 0..=3 {
|
for col in 0..=3 {
|
||||||
@@ -146,10 +144,8 @@ fn up_trim() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn down() {
|
fn down() {
|
||||||
for text in [
|
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"]]
|
||||||
["abc", "def", "ghi"],
|
{
|
||||||
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"],
|
|
||||||
] {
|
|
||||||
let mut t = TextArea::from(text);
|
let mut t = TextArea::from(text);
|
||||||
|
|
||||||
for col in 0..=3 {
|
for col in 0..=3 {
|
||||||
@@ -217,10 +213,8 @@ fn end() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn top() {
|
fn top() {
|
||||||
for text in [
|
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"]]
|
||||||
["abc", "def", "ghi"],
|
{
|
||||||
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"],
|
|
||||||
] {
|
|
||||||
let mut t = TextArea::from(text);
|
let mut t = TextArea::from(text);
|
||||||
for row in 0..=2 {
|
for row in 0..=2 {
|
||||||
for col in 0..=3 {
|
for col in 0..=3 {
|
||||||
@@ -250,10 +244,8 @@ fn top_trim() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bottom() {
|
fn bottom() {
|
||||||
for text in [
|
for text in [["abc", "def", "ghi"], ["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"]]
|
||||||
["abc", "def", "ghi"],
|
{
|
||||||
["あいう", "🐶🐱🐰", "👪🤟🏿👩🏻❤️💋👨🏾"],
|
|
||||||
] {
|
|
||||||
let mut t = TextArea::from(text);
|
let mut t = TextArea::from(text);
|
||||||
for row in 0..=2 {
|
for row in 0..=2 {
|
||||||
for col in 0..=3 {
|
for col in 0..=3 {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user