GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — id: rustfmt meta_client.rs and drop expect() in tags search parser (#… · developing-today/code@6f00e7e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pkgs/id/src
    • meta_client.rs
    • tags.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pkgs/id/src/meta_client.rs‎

Copy file name to clipboardExpand all lines: pkgs/id/src/meta_client.rs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub fn expect_ok(resp: MetaResponse) -> Result<MetaResponse> {
5353
/// limit instead. Any other read failure passes through unchanged.
5454
pub fn capped_response_error(err: ReadToEndError) -> anyhow::Error {
5555
match err {
56-
ReadToEndError::TooLong => anyhow::anyhow!(
57-
"response too large: exceeds the {MAX_RESPONSE_BYTES}-byte limit"
58-
),
56+
ReadToEndError::TooLong => {
57+
anyhow::anyhow!("response too large: exceeds the {MAX_RESPONSE_BYTES}-byte limit")
58+
}
5959
other => other.into(),
6060
}
6161
}
Collapse file

‎pkgs/id/src/tags.rs‎

Copy file name to clipboardExpand all lines: pkgs/id/src/tags.rs
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,14 +1474,18 @@ pub fn parse_search_query(input: &str) -> Vec<SearchTerm> {
14741474

14751475
// Byte index into `input`. It only ever advances by whole chars, so it
14761476
// always rests on a char boundary and slicing stays valid even when a
1477-
// separator is a multi-byte whitespace char such as NBSP (U+00A0).
1477+
// separator is a multi-byte whitespace char such as NBSP (U+00A0). The
1478+
// loops below guard on `i < input.len()`, so `chars().next()` is always
1479+
// `Some` there; the let-else form keeps that invariant panic-free.
14781480
let mut i = 0;
14791481

14801482
while i < input.len() {
14811483
// Skip whitespace: any `char::is_whitespace` char separates terms,
14821484
// not only the ASCII space.
14831485
while i < input.len() {
1484-
let ch = input[i..].chars().next().expect("i is a char boundary");
1486+
let Some(ch) = input[i..].chars().next() else {
1487+
break;
1488+
};
14851489
if !ch.is_whitespace() {
14861490
break;
14871491
}
@@ -1496,7 +1500,9 @@ pub fn parse_search_query(input: &str) -> Vec<SearchTerm> {
14961500
let start = i;
14971501
let mut in_quotes = false;
14981502
while i < input.len() {
1499-
let ch = input[i..].chars().next().expect("i is a char boundary");
1503+
let Some(ch) = input[i..].chars().next() else {
1504+
break;
1505+
};
15001506
if ch == '"' {
15011507
in_quotes = !in_quotes;
15021508
i += 1;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.