Post-formatting aesthetic and spacing corrections

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-04-27 02:39:28 +00:00
parent 1b70ef5dea
commit 222e89f6fe
17 changed files with 76 additions and 40 deletions

View File

@@ -91,10 +91,7 @@ impl PartialProxyConfig {
}
}
match (included_because, excluded_because) {
| (Some(a), Some(b)) if a.more_specific_than(b) => Some(&self.url), /* included for
* a more specific
* reason */
// than excluded
| (Some(a), Some(b)) if a.more_specific_than(b) => Some(&self.url),
| (Some(_), None) => Some(&self.url),
| _ => None,
}

View File

@@ -87,10 +87,12 @@ fn append_features(features: &mut Vec<String>, manifest: &str) -> Result<()> {
fn init_dependencies() -> Result<DepsSet> {
let manifest = Manifest::from_str(WORKSPACE_MANIFEST)?;
Ok(manifest
let deps_set = manifest
.workspace
.as_ref()
.expect("manifest has workspace section")
.dependencies
.clone())
.clone();
Ok(deps_set)
}

View File

@@ -44,6 +44,7 @@ impl Module {
.handle
.as_ref()
.expect("backing library loaded by this instance");
// SAFETY: Calls dlsym(3) on unix platforms. This might not have to be unsafe
// if wrapped in libloading with_dlerror().
let sym = unsafe { handle.get::<Prototype>(cname.as_bytes()) };

View File

@@ -27,6 +27,7 @@ pub fn to_name(path: &OsStr) -> Result<String> {
.expect("path file stem")
.to_str()
.expect("name string");
let name = name
.strip_prefix("lib")
.unwrap_or(name)

View File

@@ -23,8 +23,10 @@ impl fmt::Display for Escape<'_> {
| '"' => "&quot;",
| _ => continue,
};
fmt.write_str(&pile_o_bits[last..i])?;
fmt.write_str(s)?;
// NOTE: we only expect single byte characters here - which is fine as long as
// we only match single byte characters
last = i.saturating_add(1);

View File

@@ -1,4 +1,4 @@
use std::{fmt, str::FromStr};
use std::{fmt, marker::PhantomData, str::FromStr};
use ruma::{CanonicalJsonError, CanonicalJsonObject, canonical_json::try_from_json_map};
@@ -11,25 +11,28 @@ use crate::Result;
pub fn to_canonical_object<T: serde::Serialize>(
value: T,
) -> Result<CanonicalJsonObject, CanonicalJsonError> {
use CanonicalJsonError::SerDe;
use serde::ser::Error;
match serde_json::to_value(value).map_err(CanonicalJsonError::SerDe)? {
match serde_json::to_value(value).map_err(SerDe)? {
| serde_json::Value::Object(map) => try_from_json_map(map),
| _ =>
Err(CanonicalJsonError::SerDe(serde_json::Error::custom("Value must be an object"))),
| _ => Err(SerDe(serde_json::Error::custom("Value must be an object"))),
}
}
pub fn deserialize_from_str<
'de,
pub fn deserialize_from_str<'de, D, T, E>(deserializer: D) -> Result<T, D::Error>
where
D: serde::de::Deserializer<'de>,
T: FromStr<Err = E>,
E: fmt::Display,
>(
deserializer: D,
) -> Result<T, D::Error> {
struct Visitor<T: FromStr<Err = E>, E>(std::marker::PhantomData<T>);
impl<T: FromStr<Err = Err>, Err: fmt::Display> serde::de::Visitor<'_> for Visitor<T, Err> {
{
struct Visitor<T: FromStr<Err = E>, E>(PhantomData<T>);
impl<T, Err> serde::de::Visitor<'_> for Visitor<T, Err>
where
T: FromStr<Err = Err>,
Err: fmt::Display,
{
type Value = T;
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -43,5 +46,6 @@ pub fn deserialize_from_str<
v.parse().map_err(serde::de::Error::custom)
}
}
deserializer.deserialize_str(Visitor(std::marker::PhantomData))
deserializer.deserialize_str(Visitor(PhantomData))
}

View File

@@ -109,14 +109,11 @@ pub fn whole_unit(d: Duration) -> Unit {
| 86_400.. => Days(d.as_secs() / 86_400),
| 3_600..=86_399 => Hours(d.as_secs() / 3_600),
| 60..=3_599 => Mins(d.as_secs() / 60),
| _ => match d.as_micros() {
| 1_000_000.. => Secs(d.as_secs()),
| 1_000..=999_999 => Millis(d.subsec_millis().into()),
| _ => match d.as_nanos() {
| 1_000.. => Micros(d.subsec_micros().into()),
| _ => Nanos(d.subsec_nanos().into()),
},
},