Skip to content

Commit 731a0d3

Browse files
Kateřina ChuranováCopilot
andcommitted
fix(templated_uri): preserve error chain in remaining caused_by calls, simplify docs
- Use Into::into / ValidationError::from instead of caused_by in build_http_uri and Origin::from_str to preserve error sources - Remove unnecessary Display impl from UriUnsafeParam derive example Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4715c17 commit 731a0d3

3 files changed

Lines changed: 2 additions & 9 deletions

File tree

crates/templated_uri/src/base_uri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl BaseUri {
600600
parts.authority = Some(self.authority().clone());
601601
parts.path_and_query = Some(full_path);
602602

603-
http::Uri::from_parts(parts).map_err(ValidationError::caused_by)
603+
http::Uri::from_parts(parts).map_err(Into::into)
604604
}
605605
}
606606

crates/templated_uri/src/base_uri/origin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl std::str::FromStr for Origin {
131131
/// Returns a [`ValidationError`] if the string is not a valid origin
132132
/// (missing scheme, unsupported scheme, or invalid authority).
133133
fn from_str(s: &str) -> Result<Self, Self::Err> {
134-
let uri: http::Uri = s.parse().map_err(ValidationError::caused_by)?;
134+
let uri: http::Uri = s.parse().map_err(ValidationError::from)?;
135135
let scheme = uri.scheme().ok_or_else(|| ValidationError::caused_by("missing scheme"))?.clone();
136136
let authority = uri
137137
.authority()

crates/templated_uri/src/macros.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,10 @@ pub use templated_uri_macros::UriParam;
3636
/// # Example
3737
///
3838
/// ```
39-
/// # use std::fmt::Display;
4039
/// use templated_uri::UriUnsafeParam;
4140
///
4241
/// #[derive(UriUnsafeParam)]
4342
/// struct PathSegment(String);
44-
///
45-
/// impl Display for PathSegment {
46-
/// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47-
/// write!(f, "{}", self.0)
48-
/// }
49-
/// }
5043
/// ```
5144
///
5245
/// This allows `PathSegment` to be used in URI templates with `{+param}` syntax where

0 commit comments

Comments
 (0)