Skip to content

Commit 37cd79c

Browse files
committed
Gather all ZST structs of str together
1 parent 653b5bf commit 37cd79c

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

library/core/src/str/mod.rs

+22-26
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ use iter::{MatchesInternal, SplitNInternal};
7979

8080
use validations::truncate_to_char_boundary;
8181

82-
impl_fn_for_zst! {
83-
/// A nameable, cloneable fn type
84-
#[derive(Clone)]
85-
struct LinesAnyMap impl<'a> Fn = |line: &'a str| -> &'a str {
86-
let l = line.len();
87-
if l > 0 && line.as_bytes()[l - 1] == b'\r' { &line[0 .. l - 1] }
88-
else { line }
89-
};
90-
}
91-
9282
#[inline(never)]
9383
#[cold]
9484
#[track_caller]
@@ -2425,22 +2415,6 @@ impl str {
24252415
}
24262416
}
24272417

2428-
impl_fn_for_zst! {
2429-
#[derive(Clone)]
2430-
struct CharEscapeDebugContinue impl Fn = |c: char| -> char::EscapeDebug {
2431-
c.escape_debug_ext(false)
2432-
};
2433-
2434-
#[derive(Clone)]
2435-
struct CharEscapeUnicode impl Fn = |c: char| -> char::EscapeUnicode {
2436-
c.escape_unicode()
2437-
};
2438-
#[derive(Clone)]
2439-
struct CharEscapeDefault impl Fn = |c: char| -> char::EscapeDefault {
2440-
c.escape_default()
2441-
};
2442-
}
2443-
24442418
#[stable(feature = "rust1", since = "1.0.0")]
24452419
impl AsRef<[u8]> for str {
24462420
#[inline]
@@ -2467,6 +2441,28 @@ impl Default for &mut str {
24672441
}
24682442

24692443
impl_fn_for_zst! {
2444+
/// A nameable, cloneable fn type
2445+
#[derive(Clone)]
2446+
struct LinesAnyMap impl<'a> Fn = |line: &'a str| -> &'a str {
2447+
let l = line.len();
2448+
if l > 0 && line.as_bytes()[l - 1] == b'\r' { &line[0 .. l - 1] }
2449+
else { line }
2450+
};
2451+
2452+
#[derive(Clone)]
2453+
struct CharEscapeDebugContinue impl Fn = |c: char| -> char::EscapeDebug {
2454+
c.escape_debug_ext(false)
2455+
};
2456+
2457+
#[derive(Clone)]
2458+
struct CharEscapeUnicode impl Fn = |c: char| -> char::EscapeUnicode {
2459+
c.escape_unicode()
2460+
};
2461+
#[derive(Clone)]
2462+
struct CharEscapeDefault impl Fn = |c: char| -> char::EscapeDefault {
2463+
c.escape_default()
2464+
};
2465+
24702466
#[derive(Clone)]
24712467
struct IsWhitespace impl Fn = |c: char| -> bool {
24722468
c.is_whitespace()

0 commit comments

Comments
 (0)