Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/form_urlencoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ pub fn parse_bytes(input: &[u8], encoding_override: Option<EncodingRef>,
} else {
let (name, value) = match piece.position_elem(&b'=') {
Some(position) => (piece.slice_to(position), piece.slice_from(position + 1)),
None => if isindex { (&[], piece) } else { (piece, &[]) }
None => {
let tmp: (&[u8], &[u8]) = if isindex { (&[], piece) } else { (piece, &[]) };
tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I’d prefer [].as_slice(). Does that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the special rules for let foo = &rvalue expand the lifetime of the vector here. Those rules don't apply for [].as_slice() so you get a lifetime error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unfortunate, but oh well.

}
};
let name = replace_plus(name);
let value = replace_plus(value);
Expand Down
4 changes: 2 additions & 2 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl Host {
// TODO: Remove this check and use IDNA "domain to ASCII"
if !domain.as_slice().is_ascii() {
Err(NonAsciiDomainsNotSupportedYet)
} else if domain.as_slice().find(&[
} else if domain.as_slice().find([
'\0', '\t', '\n', '\r', ' ', '#', '%', '/', ':', '?', '@', '[', '\\', ']'
]).is_some() {
].as_slice()).is_some() {
Err(InvalidDomainCharacter)
} else {
Ok(Domain(domain.into_string().into_ascii_lower()))
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub enum Context {


pub fn parse_url(input: &str, parser: &UrlParser) -> ParseResult<Url> {
let input = input.trim_chars(&[' ', '\t', '\n', '\r', '\x0C']);
let input = input.trim_chars([' ', '\t', '\n', '\r', '\x0C'].as_slice());
let (scheme, remaining) = match parse_scheme(input, UrlParserContext) {
Some((scheme, remaining)) => (scheme, remaining),
// No-scheme state
Expand Down