Skip to content

Commit

Permalink
lib: now consume impl AsRef<str> for more convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Dec 11, 2023
1 parent 45d21bf commit dc512a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ impl<T: IoRead + IoWrite> IoReadAndWrite for T {}
///
/// ## Return value
/// [`TtfbOutcome`] or [`TtfbError`].
pub fn ttfb(input: String, allow_insecure_certificates: bool) -> Result<TtfbOutcome, TtfbError> {
pub fn ttfb(
input: impl AsRef<str>,
allow_insecure_certificates: bool,
) -> Result<TtfbOutcome, TtfbError> {
let input = input.as_ref();
if input.is_empty() {
return Err(TtfbError::InvalidUrl(InvalidUrlError::MissingInput));
}
let input = input.to_string();
let input = prepend_default_scheme_if_necessary(input);
let url = parse_input_as_url(&input)?;
assert_scheme_is_allowed(&url)?;
Expand Down

0 comments on commit dc512a3

Please sign in to comment.