Skip to content

Strip trailing ampersand#3

Open
maxdeviant wants to merge 1 commit into
FGRibreau:masterfrom
deviant-forks:strip-trailing-ampersand
Open

Strip trailing ampersand#3
maxdeviant wants to merge 1 commit into
FGRibreau:masterfrom
deviant-forks:strip-trailing-ampersand

Conversation

@maxdeviant
Copy link
Copy Markdown

This PR makes it so the trailing ampersand (&) is stripped when using stringify.

Fixes #2.

Comment thread src/lib.rs
acc + tuple.0 + "=" + tuple.1 + "&"
})
.trim_end_matches('&')
.to_string()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not 100% sure, but I think this might add an additional allocation.

It seemed like the best approach given the possibility space I could think of; not sure if there's room/a need to optimize further.

Comment thread src/lib.rs
/// extern crate querystring;
///
/// assert_eq!(querystring::stringify(vec![("foo", "bar"), ("baz", "qux")]), "foo=bar&baz=qux&");
/// assert_eq!(querystring::stringify(vec![("foo", "bar"), ("baz", "qux")]), "foo=bar&baz=qux");
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I updated the doctest here, but am happy to add additional tests!

@maxdeviant maxdeviant force-pushed the strip-trailing-ampersand branch from dc9570c to 7a5eb0e Compare July 28, 2022 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reason for Trailing Ampersand?

1 participant