bxcore, bxctl: drop the skeletons' instruction comments; usage indent
M5b review, findings 3 and 4: the instruction comments tasks 03 and 04 left inside filled bodies, and a space of indent task 11 added to four lines of bxctl's usage text. No behaviour changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -130,9 +130,6 @@ const PRIVATE_USE: &[(u32, u32)] = &[(0xE000, 0xF8FF), (0xF0000, 0xFFFFD), (0x10
|
||||
|
||||
/// The byte offset of the first character in `text` for which `rule` is true.
|
||||
fn first_char(text: &str, rule: fn(char) -> bool) -> Option<usize> {
|
||||
// `text.char_indices()` gives each character with its byte offset. `find` the first pair
|
||||
// whose character `rule` accepts, and `map` it to its offset. A byte offset, not a count of
|
||||
// characters: a test puts a two-byte character first.
|
||||
text.char_indices()
|
||||
.find(|&(_, c)| rule(c))
|
||||
.map(|(at, _)| at)
|
||||
@@ -140,7 +137,6 @@ fn first_char(text: &str, rule: fn(char) -> bool) -> Option<usize> {
|
||||
|
||||
/// A control character other than line feed and tab.
|
||||
fn control(c: char) -> bool {
|
||||
// `c.is_control()`, and `c` is neither '\n' nor '\t'.
|
||||
c.is_control() && c != '\n' && c != '\t'
|
||||
}
|
||||
|
||||
@@ -155,8 +151,6 @@ pub(super) fn invisible(c: char) -> bool {
|
||||
|
||||
/// A character in one of the `PRIVATE_USE` ranges.
|
||||
fn private_use(c: char) -> bool {
|
||||
// As `invisible` does for `DEFAULT_IGNORABLE`: `u32::from(c)` is inside one of the inclusive
|
||||
// `(low, high)` ranges of `PRIVATE_USE`.
|
||||
let code = u32::from(c);
|
||||
PRIVATE_USE
|
||||
.iter()
|
||||
@@ -165,8 +159,6 @@ fn private_use(c: char) -> bool {
|
||||
|
||||
/// U+FDD0 to U+FDEF, and the last two code points of every plane (U+FFFE, U+FFFF, U+1FFFE, …).
|
||||
fn noncharacter(c: char) -> bool {
|
||||
// With `code = u32::from(c)`: `(0xFDD0..=0xFDEF).contains(&code)`, or `code & 0xFFFE ==
|
||||
// 0xFFFE`, which is true for exactly the last two code points of each of the 17 planes.
|
||||
let code = u32::from(c);
|
||||
(0xFDD0..=0xFDEF).contains(&code) || code & 0xFFFE == 0xFFFE
|
||||
}
|
||||
@@ -304,9 +296,6 @@ fn find_secret(text: &str, secrets: &[Secret]) -> Option<usize> {
|
||||
/// Whether a prefix right after `before` starts a word: `before` is empty, or its last character
|
||||
/// is not an ASCII letter or digit, `_` or `-`.
|
||||
fn starts_word(before: &str) -> bool {
|
||||
// Take `before.chars().next_back()`, its last character. `None` (an empty `before`) is a
|
||||
// start. Otherwise it is a start unless that character `is_ascii_alphanumeric()` or is '_' or
|
||||
// '-': `!before.chars().next_back().is_some_and(|c| …)`.
|
||||
!before
|
||||
.chars()
|
||||
.next_back()
|
||||
@@ -317,10 +306,6 @@ fn starts_word(before: &str) -> bool {
|
||||
/// `secret.min..=secret.max`, and, if `secret.mixed`, which holds an ASCII upper-case letter and
|
||||
/// an ASCII digit.
|
||||
fn key_run(after: &str, secret: &Secret) -> bool {
|
||||
// Walk `after.chars().take_while(|&c| (secret.key)(c))`, counting the characters and noting
|
||||
// whether any `is_ascii_uppercase()` and any `is_ascii_digit()`. True when the count is in
|
||||
// `(secret.min..=secret.max)` (`contains(&count)`) and, if `secret.mixed`, both were seen.
|
||||
// What follows the run does not matter.
|
||||
let mut count = 0usize;
|
||||
let mut has_upper = false;
|
||||
let mut has_digit = false;
|
||||
@@ -339,11 +324,6 @@ const PRIVATE_KEY_ENDS: &[&str] = &["PRIVATE KEY-----", "PRIVATE KEY BLOCK-----"
|
||||
/// The byte offset of the first line whose text, white space aside, starts `-----BEGIN` and
|
||||
/// ends with one of `PRIVATE_KEY_ENDS`.
|
||||
fn private_key(text: &str) -> Option<usize> {
|
||||
// For each `(at, _)` in `text.match_indices("-----BEGIN")`: `text.split_at_checked(at)?`
|
||||
// gives `(before, from)`; the line up to `at` is `before.rsplit('\n').next()`, and the line
|
||||
// from `at` is `from.split('\n').next()`, each `.unwrap_or_default()`. Return `Some(at)` for
|
||||
// the first `at` where the first line `trim()`s to empty and the second, `trim_end()`ed, ends
|
||||
// with one of `PRIVATE_KEY_ENDS` (`.iter().any(|end| line.ends_with(end))`). Else `None`.
|
||||
for (at, _) in text.match_indices("-----BEGIN") {
|
||||
let (before, from) = text.split_at_checked(at).unwrap_or_default();
|
||||
let first_line = before.rsplit('\n').next().unwrap_or_default();
|
||||
@@ -361,7 +341,5 @@ fn private_key(text: &str) -> Option<usize> {
|
||||
|
||||
/// The byte offset of the first listed tag, matched exactly as `neutralise` matches.
|
||||
fn listed_tag(text: &str) -> Option<usize> {
|
||||
// `next_tag(text)` (in `tags.rs`) gives the text before the first listed tag, the tag, and
|
||||
// the text after it: map that to the length of the text before.
|
||||
next_tag(text).map(|(before, _, _)| before.len())
|
||||
}
|
||||
|
||||
@@ -105,10 +105,6 @@ pub fn neutralise(text: &str) -> Cow<'_, str> {
|
||||
|
||||
/// The first listed tag in `text`: the text before it, the tag, and the text after it.
|
||||
pub(super) fn next_tag(text: &str) -> Option<(&str, &'static Tag, &str)> {
|
||||
// For each `(at, _)` of `text.match_indices('<')`: `let (before, from) =
|
||||
// text.split_at_checked(at)?;`, then `TAGS.iter().find(|tag| from.starts_with(tag.text))`.
|
||||
// If it finds one: `let after = from.get(tag.text.len()..)?;` and return
|
||||
// `Some((before, tag, after))`. After the loop, `None`.
|
||||
for (at, _) in text.match_indices('<') {
|
||||
let (before, from) = text.split_at_checked(at)?;
|
||||
if let Some(tag) = TAGS.iter().find(|tag| from.starts_with(tag.text)) {
|
||||
@@ -121,8 +117,6 @@ pub(super) fn next_tag(text: &str) -> Option<(&str, &'static Tag, &str)> {
|
||||
|
||||
/// Appends `tag.text` to `out` with `<` written as `<` and `>` as `>`.
|
||||
fn push_escaped(out: &mut String, tag: &Tag) {
|
||||
// For each `c` of `tag.text.chars()`, a `match c`: `'<'` pushes the string "<", `'>'`
|
||||
// pushes ">", and any other character is pushed as it is (`out.push(c)`).
|
||||
for c in tag.text.chars() {
|
||||
match c {
|
||||
'<' => out.push_str("<"),
|
||||
|
||||
Reference in New Issue
Block a user