Skip to content

Commit ee22b20

Browse files
committed
nostr: add new and empty constructors to UncheckedUrl
1 parent 8d035ee commit ee22b20

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

crates/nostr/src/types/url.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,24 @@ impl From<ParseError> for Error {
3333
}
3434

3535
/// Unchecked Url
36-
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord, Default)]
36+
#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
3737
pub struct UncheckedUrl(String);
3838

39+
impl UncheckedUrl {
40+
/// New unchecked url
41+
pub fn new<S>(url: S) -> Self
42+
where
43+
S: Into<String>,
44+
{
45+
Self(url.into())
46+
}
47+
48+
/// Empty unchecked url
49+
pub fn empty() -> Self {
50+
Self(String::new())
51+
}
52+
}
53+
3954
impl<S> From<S> for UncheckedUrl
4055
where
4156
S: Into<String>,

0 commit comments

Comments
 (0)