Skip to content

Commit 82eb04c

Browse files
authored
Merge pull request #4777 from Joining7943/tail-change-text-static-to-const
'tail': Change static global variables to const
2 parents 90e0d30 + c6f6c87 commit 82eb04c

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

src/uu/tail/src/args.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ const USAGE: &str = help_usage!("tail.md");
2424

2525
pub mod options {
2626
pub mod verbosity {
27-
pub static QUIET: &str = "quiet";
28-
pub static VERBOSE: &str = "verbose";
27+
pub const QUIET: &str = "quiet";
28+
pub const VERBOSE: &str = "verbose";
2929
}
30-
pub static BYTES: &str = "bytes";
31-
pub static FOLLOW: &str = "follow";
32-
pub static LINES: &str = "lines";
33-
pub static PID: &str = "pid";
34-
pub static SLEEP_INT: &str = "sleep-interval";
35-
pub static ZERO_TERM: &str = "zero-terminated";
36-
pub static DISABLE_INOTIFY_TERM: &str = "-disable-inotify"; // NOTE: three hyphens is correct
37-
pub static USE_POLLING: &str = "use-polling";
38-
pub static RETRY: &str = "retry";
39-
pub static FOLLOW_RETRY: &str = "F";
40-
pub static MAX_UNCHANGED_STATS: &str = "max-unchanged-stats";
41-
pub static ARG_FILES: &str = "files";
42-
pub static PRESUME_INPUT_PIPE: &str = "-presume-input-pipe"; // NOTE: three hyphens is correct
30+
pub const BYTES: &str = "bytes";
31+
pub const FOLLOW: &str = "follow";
32+
pub const LINES: &str = "lines";
33+
pub const PID: &str = "pid";
34+
pub const SLEEP_INT: &str = "sleep-interval";
35+
pub const ZERO_TERM: &str = "zero-terminated";
36+
pub const DISABLE_INOTIFY_TERM: &str = "-disable-inotify"; // NOTE: three hyphens is correct
37+
pub const USE_POLLING: &str = "use-polling";
38+
pub const RETRY: &str = "retry";
39+
pub const FOLLOW_RETRY: &str = "F";
40+
pub const MAX_UNCHANGED_STATS: &str = "max-unchanged-stats";
41+
pub const ARG_FILES: &str = "files";
42+
pub const PRESUME_INPUT_PIPE: &str = "-presume-input-pipe"; // NOTE: three hyphens is correct
4343
}
4444

4545
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -470,12 +470,11 @@ pub fn parse_args(args: impl uucore::Args) -> UResult<Settings> {
470470

471471
pub fn uu_app() -> Command {
472472
#[cfg(target_os = "linux")]
473-
pub static POLLING_HELP: &str = "Disable 'inotify' support and use polling instead";
473+
const POLLING_HELP: &str = "Disable 'inotify' support and use polling instead";
474474
#[cfg(all(unix, not(target_os = "linux")))]
475-
pub static POLLING_HELP: &str = "Disable 'kqueue' support and use polling instead";
475+
const POLLING_HELP: &str = "Disable 'kqueue' support and use polling instead";
476476
#[cfg(target_os = "windows")]
477-
pub static POLLING_HELP: &str =
478-
"Disable 'ReadDirectoryChanges' support and use polling instead";
477+
const POLLING_HELP: &str = "Disable 'ReadDirectoryChanges' support and use polling instead";
479478

480479
Command::new(uucore::util_name())
481480
.version(crate_version!())

src/uu/tail/src/text.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66
// spell-checker:ignore (ToDO) kqueue
77

8-
pub static DASH: &str = "-";
9-
pub static DEV_STDIN: &str = "/dev/stdin";
10-
pub static STDIN_HEADER: &str = "standard input";
11-
pub static NO_FILES_REMAINING: &str = "no files remaining";
12-
pub static NO_SUCH_FILE: &str = "No such file or directory";
13-
pub static BECOME_INACCESSIBLE: &str = "has become inaccessible";
14-
pub static BAD_FD: &str = "Bad file descriptor";
8+
pub const DASH: &str = "-";
9+
pub const DEV_STDIN: &str = "/dev/stdin";
10+
pub const STDIN_HEADER: &str = "standard input";
11+
pub const NO_FILES_REMAINING: &str = "no files remaining";
12+
pub const NO_SUCH_FILE: &str = "No such file or directory";
13+
pub const BECOME_INACCESSIBLE: &str = "has become inaccessible";
14+
pub const BAD_FD: &str = "Bad file descriptor";
1515
#[cfg(target_os = "linux")]
16-
pub static BACKEND: &str = "inotify";
16+
pub const BACKEND: &str = "inotify";
1717
#[cfg(all(unix, not(target_os = "linux")))]
18-
pub static BACKEND: &str = "kqueue";
18+
pub const BACKEND: &str = "kqueue";
1919
#[cfg(target_os = "windows")]
20-
pub static BACKEND: &str = "ReadDirectoryChanges";
21-
pub static FD0: &str = "/dev/fd/0";
22-
pub static IS_A_DIRECTORY: &str = "Is a directory";
23-
pub static DEV_TTY: &str = "/dev/tty";
24-
pub static DEV_PTMX: &str = "/dev/ptmx";
20+
pub const BACKEND: &str = "ReadDirectoryChanges";
21+
pub const FD0: &str = "/dev/fd/0";
22+
pub const IS_A_DIRECTORY: &str = "Is a directory";
23+
pub const DEV_TTY: &str = "/dev/tty";
24+
pub const DEV_PTMX: &str = "/dev/ptmx";

tests/by-util/test_tail.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ use tail::chunks::BUFFER_SIZE as CHUNK_BUFFER_SIZE;
3636
))]
3737
use tail::text;
3838

39-
static FOOBAR_TXT: &str = "foobar.txt";
40-
static FOOBAR_2_TXT: &str = "foobar2.txt";
41-
static FOOBAR_WITH_NULL_TXT: &str = "foobar_with_null.txt";
39+
const FOOBAR_TXT: &str = "foobar.txt";
40+
const FOOBAR_2_TXT: &str = "foobar2.txt";
41+
const FOOBAR_WITH_NULL_TXT: &str = "foobar_with_null.txt";
4242
#[allow(dead_code)]
43-
static FOLLOW_NAME_TXT: &str = "follow_name.txt";
43+
const FOLLOW_NAME_TXT: &str = "follow_name.txt";
4444
#[allow(dead_code)]
45-
static FOLLOW_NAME_SHORT_EXP: &str = "follow_name_short.expected";
45+
const FOLLOW_NAME_SHORT_EXP: &str = "follow_name_short.expected";
4646
#[allow(dead_code)]
47-
static FOLLOW_NAME_EXP: &str = "follow_name.expected";
47+
const FOLLOW_NAME_EXP: &str = "follow_name.expected";
4848

4949
#[cfg(not(windows))]
5050
const DEFAULT_SLEEP_INTERVAL_MILLIS: u64 = 1000;

0 commit comments

Comments
 (0)