Skip to content

Commit 997a9b9

Browse files
authored
Merge pull request #151 from itsjunetime/june/update_to_2024
Update to edition 2024
2 parents 7f3c514 + d63910b commit 997a9b9

File tree

21 files changed

+104
-77
lines changed

21 files changed

+104
-77
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "minus"
33
version = "5.6.1"
44
authors = ["Arijit Dey <[email protected]>"]
5-
edition = "2018"
5+
edition = "2024"
66
license = "MIT OR Apache-2.0"
77
documentation = "https://docs.rs/minus"
88
repository = "https://github.com/AMythicDev/minus"

examples/color-output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crossterm::style::{Color, ResetColor, SetForegroundColor};
2-
use minus::{error::MinusError, page_all, Pager};
2+
use minus::{Pager, error::MinusError, page_all};
33
use std::fmt::Write;
44

55
fn main() -> Result<(), MinusError> {

examples/static-no-overflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use minus::error::MinusError;
2-
use minus::{page_all, Pager};
2+
use minus::{Pager, page_all};
33
use std::fmt::Write;
44

55
fn main() -> Result<(), MinusError> {

src/core/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use std::fmt::Debug;
77

88
use crate::{
9-
input::{InputClassifier, InputEvent},
109
ExitStrategy, LineNumbers,
10+
input::{InputClassifier, InputEvent},
1111
};
1212

1313
#[cfg(feature = "search")]

src/core/ev_handler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
33
use std::convert::TryInto;
44
use std::io::Write;
5-
use std::sync::{atomic::AtomicBool, Arc};
5+
use std::sync::{Arc, atomic::AtomicBool};
66

77
#[cfg(feature = "search")]
88
use parking_lot::{Condvar, Mutex};
99

10-
use super::utils::display::{self, AppendStyle};
1110
use super::CommandQueue;
11+
use super::utils::display::{self, AppendStyle};
1212
use super::{commands::Command, utils::term};
1313
#[cfg(feature = "search")]
1414
use crate::search;
15-
use crate::{error::MinusError, input::InputEvent, PagerState};
15+
use crate::{PagerState, error::MinusError, input::InputEvent};
1616

1717
/// Respond based on the type of command
1818
///
@@ -336,12 +336,12 @@ pub fn handle_event(
336336
mod tests {
337337
use super::super::commands::Command;
338338
use super::handle_event;
339-
use crate::{minus_core::CommandQueue, ExitStrategy, PagerState, RunMode};
339+
use crate::{ExitStrategy, PagerState, RunMode, minus_core::CommandQueue};
340340
#[cfg(feature = "search")]
341341
use parking_lot::{Condvar, Mutex};
342342
#[cfg(feature = "search")]
343343
use std::sync::LazyLock;
344-
use std::sync::{atomic::AtomicBool, Arc};
344+
use std::sync::{Arc, atomic::AtomicBool};
345345

346346
// Tests constants
347347
#[cfg(feature = "search")]

src/core/init.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
#[cfg(feature = "static_output")]
1212
use crate::minus_core::utils::display;
1313
use crate::{
14+
Pager, PagerState,
1415
error::MinusError,
1516
input::InputEvent,
1617
minus_core::{
18+
RunMode,
1719
commands::Command,
1820
ev_handler::handle_event,
1921
utils::{display::draw_full, term},
20-
RunMode,
2122
},
22-
Pager, PagerState,
2323
};
2424

2525
use crossbeam_channel::{Receiver, Sender, TrySendError};
2626
use crossterm::event;
2727
use std::{
28-
io::{stdout, Stdout},
28+
io::{Stdout, stdout},
2929
panic,
3030
sync::{
31-
atomic::{AtomicBool, Ordering},
3231
Arc,
32+
atomic::{AtomicBool, Ordering},
3333
},
3434
};
3535

@@ -40,7 +40,7 @@ use {super::utils::display::write_raw_lines, crossterm::tty::IsTty};
4040
use parking_lot::Condvar;
4141
use parking_lot::Mutex;
4242

43-
use super::{utils::display::draw_for_change, CommandQueue, RUNMODE};
43+
use super::{CommandQueue, RUNMODE, utils::display::draw_for_change};
4444

4545
/// The main entry point of minus
4646
///
@@ -88,7 +88,10 @@ pub fn init_core(pager: &Pager, rm: RunMode) -> std::result::Result<(), MinusErr
8888

8989
{
9090
let mut runmode = super::RUNMODE.lock();
91-
assert!(runmode.is_uninitialized(), "Failed to set the RUNMODE. This is caused probably because another instance of minus is already running");
91+
assert!(
92+
runmode.is_uninitialized(),
93+
"Failed to set the RUNMODE. This is caused probably because another instance of minus is already running"
94+
);
9295
*runmode = rm;
9396
drop(runmode);
9497
}

src/core/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ impl CommandQueue {
4545
/// This function will panic if it is called in an environment where [RUNMODE] is
4646
/// uninitialized.
4747
pub fn push_back(&mut self, value: Command) {
48-
assert!(!RUNMODE.lock().is_uninitialized(), "CommandQueue::push_back() caled when RUNMODE is not set. This is most likely a bug. Please report the issue on minus's issue tracker on Github.");
48+
assert!(
49+
!RUNMODE.lock().is_uninitialized(),
50+
"CommandQueue::push_back() caled when RUNMODE is not set. This is most likely a bug. Please report the issue on minus's issue tracker on Github."
51+
);
4952
self.0.push_back(value);
5053
}
5154
/// Store `value` without checking [RUNMODE].

src/core/utils/display/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{cmp::Ordering, convert::TryInto, io::Write};
1010

1111
use super::term;
1212
use crate::screen::Row;
13-
use crate::{error::MinusError, minus_core, LineNumbers, PagerState};
13+
use crate::{LineNumbers, PagerState, error::MinusError, minus_core};
1414

1515
/// How should the incoming text be drawn on the screen
1616
#[derive(Debug, PartialEq, Eq)]

src/core/utils/display/tests.rs

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ fn draw_short_no_line_numbers() {
233233

234234
assert!(draw_full(&mut out, &mut pager).is_ok());
235235

236-
assert!(String::from_utf8(out)
237-
.expect("Should have written valid UTF-8")
238-
.contains("\rA line\n\rAnother line"));
236+
assert!(
237+
String::from_utf8(out)
238+
.expect("Should have written valid UTF-8")
239+
.contains("\rA line\n\rAnother line")
240+
);
239241
assert_eq!(pager.upper_mark, 0);
240242

241243
let mut out = Vec::with_capacity(lines.len());
@@ -245,9 +247,11 @@ fn draw_short_no_line_numbers() {
245247

246248
// The number of lines is less than 'rows' so 'upper_mark' will be 0 even
247249
// if we set it to 1. This is done because everything can be displayed without problems.
248-
assert!(String::from_utf8(out)
249-
.expect("Should have written valid UTF-8")
250-
.contains("\rA line\n\rAnother line"));
250+
assert!(
251+
String::from_utf8(out)
252+
.expect("Should have written valid UTF-8")
253+
.contains("\rA line\n\rAnother line")
254+
);
251255
assert_eq!(pager.upper_mark, 0);
252256
}
253257

@@ -264,9 +268,11 @@ fn draw_long_no_line_numbers() {
264268

265269
assert!(draw_full(&mut out, &mut pager).is_ok());
266270

267-
assert!(String::from_utf8(out)
268-
.expect("Should have written valid UTF-8")
269-
.contains("\rA line\n\rAnother line"));
271+
assert!(
272+
String::from_utf8(out)
273+
.expect("Should have written valid UTF-8")
274+
.contains("\rA line\n\rAnother line")
275+
);
270276
assert_eq!(pager.upper_mark, 0);
271277

272278
// This ensures that asking for a position other than 0 works.
@@ -275,9 +281,11 @@ fn draw_long_no_line_numbers() {
275281

276282
assert!(draw_full(&mut out, &mut pager).is_ok());
277283

278-
assert!(String::from_utf8(out)
279-
.expect("Should have written valid UTF-8")
280-
.contains("\rAnother line\n\rThird line"));
284+
assert!(
285+
String::from_utf8(out)
286+
.expect("Should have written valid UTF-8")
287+
.contains("\rAnother line\n\rThird line")
288+
);
281289
assert_eq!(pager.upper_mark, 1);
282290

283291
// This test ensures that as much text as possible will be displayed, even
@@ -287,9 +295,11 @@ fn draw_long_no_line_numbers() {
287295

288296
assert!(draw_full(&mut out, &mut pager).is_ok());
289297

290-
assert!(String::from_utf8(out)
291-
.expect("Should have written valid UTF-8")
292-
.contains("\rThird line\n\rFourth line"));
298+
assert!(
299+
String::from_utf8(out)
300+
.expect("Should have written valid UTF-8")
301+
.contains("\rThird line\n\rFourth line")
302+
);
293303
assert_eq!(pager.upper_mark, 2);
294304
}
295305

@@ -303,9 +313,11 @@ fn draw_short_with_line_numbers() {
303313
pager.format_lines();
304314

305315
assert!(draw_full(&mut out, &mut pager).is_ok());
306-
assert!(String::from_utf8(out)
307-
.expect("Should have written valid UTF-8")
308-
.contains("\r 1. A line\n\r 2. Another line"));
316+
assert!(
317+
String::from_utf8(out)
318+
.expect("Should have written valid UTF-8")
319+
.contains("\r 1. A line\n\r 2. Another line")
320+
);
309321
assert_eq!(pager.upper_mark, 0);
310322

311323
let mut out = Vec::with_capacity(lines.len());
@@ -315,9 +327,11 @@ fn draw_short_with_line_numbers() {
315327

316328
// The number of lines is less than 'rows' so 'upper_mark' will be 0 even
317329
// if we set it to 1. This is done because everything can be displayed without problems.
318-
assert!(String::from_utf8(out)
319-
.expect("Should have written valid UTF-8")
320-
.contains("\r 1. A line\n\r 2. Another line"));
330+
assert!(
331+
String::from_utf8(out)
332+
.expect("Should have written valid UTF-8")
333+
.contains("\r 1. A line\n\r 2. Another line")
334+
);
321335
assert_eq!(pager.upper_mark, 0);
322336
}
323337

@@ -335,9 +349,11 @@ fn draw_long_with_line_numbers() {
335349

336350
assert!(draw_full(&mut out, &mut pager).is_ok());
337351

338-
assert!(String::from_utf8(out)
339-
.expect("Should have written valid UTF-8")
340-
.contains("\r 1. A line\n\r 2. Another line"));
352+
assert!(
353+
String::from_utf8(out)
354+
.expect("Should have written valid UTF-8")
355+
.contains("\r 1. A line\n\r 2. Another line")
356+
);
341357
assert_eq!(pager.upper_mark, 0);
342358

343359
// This ensures that asking for a position other than 0 works.
@@ -346,9 +362,11 @@ fn draw_long_with_line_numbers() {
346362

347363
assert!(draw_full(&mut out, &mut pager).is_ok());
348364

349-
assert!(String::from_utf8(out)
350-
.expect("Should have written valid UTF-8")
351-
.contains("\r 2. Another line\n\r 3. Third line"));
365+
assert!(
366+
String::from_utf8(out)
367+
.expect("Should have written valid UTF-8")
368+
.contains("\r 2. Another line\n\r 3. Third line")
369+
);
352370
assert_eq!(pager.upper_mark, 1);
353371

354372
// This test ensures that as much text as possible will be displayed, even
@@ -358,9 +376,11 @@ fn draw_long_with_line_numbers() {
358376

359377
assert!(draw_full(&mut out, &mut pager).is_ok());
360378

361-
assert!(String::from_utf8(out)
362-
.expect("Should have written valid UTF-8")
363-
.contains("\r 3. Third line\n\r 4. Fourth line"));
379+
assert!(
380+
String::from_utf8(out)
381+
.expect("Should have written valid UTF-8")
382+
.contains("\r 3. Third line\n\r 4. Fourth line")
383+
);
364384
assert_eq!(pager.upper_mark, 2);
365385
}
366386

@@ -439,9 +459,11 @@ fn test_draw_no_overflow() {
439459
pager.screen.orig_text = TEXT.to_string();
440460
pager.format_lines();
441461
draw_full(&mut out, &mut pager).unwrap();
442-
assert!(String::from_utf8(out)
443-
.expect("Should have written valid UTF-8")
444-
.contains(TEXT));
462+
assert!(
463+
String::from_utf8(out)
464+
.expect("Should have written valid UTF-8")
465+
.contains(TEXT)
466+
);
445467
}
446468

447469
#[cfg(test)]

src/dynamic_pager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::Pager;
12
use crate::error::MinusError;
23
use crate::minus_core::init;
3-
use crate::Pager;
44

55
/// Starts a asynchronously running pager
66
///

0 commit comments

Comments
 (0)