This commit is contained in:
Scott Lamb 2024-02-12 17:32:37 -08:00
parent f3da22fc5c
commit f385215d6e
6 changed files with 11 additions and 11 deletions

View File

@ -60,14 +60,14 @@ type FileMap = std::collections::HashMap<String, File, ahash::RandomState>;
fn stringify_files(files: &FileMap) -> Result<String, std::fmt::Error> { fn stringify_files(files: &FileMap) -> Result<String, std::fmt::Error> {
let mut buf = String::new(); let mut buf = String::new();
write!(buf, "const FILES: [BuildFile; {}] = [\n", files.len())?; writeln!(buf, "const FILES: [BuildFile; {}] = [", files.len())?;
for (bare_path, file) in files { for (bare_path, file) in files {
let include_path = &file.include_path; let include_path = &file.include_path;
let etag = file.etag.to_hex(); let etag = file.etag.to_hex();
let encoding = file.encoding.to_str(); let encoding = file.encoding.to_str();
write!(buf, " BuildFile {{ bare_path: {bare_path:?}, data: include_bytes!({include_path:?}), etag: {etag:?}, encoding: {encoding} }},\n")?; writeln!(buf, " BuildFile {{ bare_path: {bare_path:?}, data: include_bytes!({include_path:?}), etag: {etag:?}, encoding: {encoding} }},")?;
} }
write!(buf, "];\n")?; writeln!(buf, "];")?;
Ok(buf) Ok(buf)
} }

View File

@ -345,7 +345,7 @@ fn compare_stream(
stream stream
.recordings .recordings
.entry(id.recording()) .entry(id.recording())
.or_insert_with(Recording::default) .or_default()
.recording_row = Some(s); .recording_row = Some(s);
} }
} }
@ -382,7 +382,7 @@ fn compare_stream(
stream stream
.recordings .recordings
.entry(id.recording()) .entry(id.recording())
.or_insert_with(Recording::default) .or_default()
.playback_row = Some(s); .playback_row = Some(s);
} }
} }
@ -405,7 +405,7 @@ fn compare_stream(
stream stream
.recordings .recordings
.entry(id.recording()) .entry(id.recording())
.or_insert_with(Recording::default) .or_default()
.integrity_row = true; .integrity_row = true;
} }
} }

View File

@ -102,7 +102,7 @@ impl Value for SignalValue {
type Change = SignalChange; type Change = SignalChange;
fn apply(&mut self, c: &SignalChange) { fn apply(&mut self, c: &SignalChange) {
if self.states.len() < usize::try_from(c.new_state).unwrap() { if self.states.len() < usize::from(c.new_state) {
self.states.resize(c.new_state as usize, 0); self.states.resize(c.new_state as usize, 0);
} }
@ -117,7 +117,7 @@ impl Value for SignalValue {
if c.old_state > 0 { if c.old_state > 0 {
// remove from old state. // remove from old state.
let i = usize::try_from(c.old_state).unwrap() - 1; let i = usize::from(c.old_state) - 1;
assert!( assert!(
self.states.len() > i, self.states.len() > i,
"no such old state: s={self:?} c={c:?}" "no such old state: s={self:?} c={c:?}"

View File

@ -183,7 +183,7 @@ fn get_preopened_sockets() -> Result<FastHashMap<String, Listener>, Error> {
fn read_config(path: &Path) -> Result<ConfigFile, Error> { fn read_config(path: &Path) -> Result<ConfigFile, Error> {
let config = std::fs::read(path)?; let config = std::fs::read(path)?;
let config = std::str::from_utf8(&config).map_err(|e| err!(InvalidArgument, source(e)))?; let config = std::str::from_utf8(&config).map_err(|e| err!(InvalidArgument, source(e)))?;
let config = toml::from_str(&config).map_err(|e| err!(InvalidArgument, source(e)))?; let config = toml::from_str(config).map_err(|e| err!(InvalidArgument, source(e)))?;
Ok(config) Ok(config)
} }

View File

@ -145,7 +145,7 @@ where
// (from the preceding slice) the start of its range. // (from the preceding slice) the start of its range.
let (i, slice_start) = match self.slices.binary_search_by_key(&range.start, |s| s.end()) { let (i, slice_start) = match self.slices.binary_search_by_key(&range.start, |s| s.end()) {
Ok(i) => (i + 1, self.slices[i].end()), // desired start == slice i's end; first is i+1! Ok(i) => (i + 1, self.slices[i].end()), // desired start == slice i's end; first is i+1!
Err(i) if i == 0 => (0, 0), // desired start < slice 0's end; first is 0. Err(0) => (0, 0), // desired start < slice 0's end; first is 0.
Err(i) => (i, self.slices[i - 1].end()), // desired start < slice i's end; first is i. Err(i) => (i, self.slices[i - 1].end()), // desired start < slice i's end; first is i.
}; };

View File

@ -74,7 +74,7 @@ impl Ui {
); );
hdrs.insert(header::CONTENT_TYPE, HeaderValue::from_static(content_type)); hdrs.insert(header::CONTENT_TYPE, HeaderValue::from_static(content_type));
let e = node.into_file_entity(hdrs).err_kind(ErrorKind::Internal)?; let e = node.into_file_entity(hdrs).err_kind(ErrorKind::Internal)?;
Ok(http_serve::serve(e, &req)) Ok(http_serve::serve(e, req))
} }
#[cfg(feature = "bundled-ui")] #[cfg(feature = "bundled-ui")]
Ui::Bundled(ui) => { Ui::Bundled(ui) => {