pub struct Url(/* private fields */);
Expand description
§Url: Parse impl ToString
into a valid URL
Call the parse()
method to parse impl ToString
into a valid URL.
Implementations§
Source§impl Url
impl Url
Sourcepub fn parse(url: impl ToString) -> Result<Self, TypeError>
pub fn parse(url: impl ToString) -> Result<Self, TypeError>
Parses a string into a valid URL.
§Arguments
url
- A string that implementsToString
.
§Returns
Returns Ok(Url)
if the input string is a valid URL, otherwise returns Err(TypeError)
.
§Examples
use custom_type::Url;
let valid_url = Url::parse("https://example.com");
assert!(valid_url.is_ok());
let invalid_url = Url::parse("example.com");
assert!(invalid_url.is_err());
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Url
impl<'de> Deserialize<'de> for Url
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Url
Auto Trait Implementations§
impl Freeze for Url
impl RefUnwindSafe for Url
impl Send for Url
impl Sync for Url
impl Unpin for Url
impl UnwindSafe for Url
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more