From b6fbbcaf8ae3448d2bda41ef0165a3b31003ef0c Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 21 Apr 2016 22:59:46 +0200 Subject: [PATCH 1/2] Rename mutate_query_pairs to query_pairs_mut. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is more in line with standard library convensions, and we’ll add path_segments_mut later. --- src/form_urlencoded.rs | 2 +- src/lib.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/form_urlencoded.rs b/src/form_urlencoded.rs index 16fbeb51..f4a65550 100644 --- a/src/form_urlencoded.rs +++ b/src/form_urlencoded.rs @@ -238,7 +238,7 @@ impl<'a> Target for &'a mut String { // (and so can not be constructed with struct literal syntax outside of this crate), // * It has no constructor // * It is only visible (on the type level) to users in the return type of -// `Url::mutate_query_pairs` which is `Serializer` +// `Url::query_pairs_mut` which is `Serializer` // * `Serializer` keeps its target in a private field // * Unlike in other `Target` impls, `UrlQuery::finished` does not return `Self`. impl<'a> Target for ::UrlQuery<'a> { diff --git a/src/lib.rs b/src/lib.rs index 804e6396..9d410efe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -645,11 +645,11 @@ impl Url { /// let mut url = Url::parse("https://example.net?lang=fr#nav").unwrap(); /// assert_eq!(url.query(), Some("lang=fr")); /// - /// url.mutate_query_pairs().append_pair("foo", "bar"); + /// url.query_pairs_mut().append_pair("foo", "bar"); /// assert_eq!(url.query(), Some("lang=fr&foo=bar")); /// assert_eq!(url.as_str(), "https://example.net/?lang=fr&foo=bar#nav"); /// - /// url.mutate_query_pairs() + /// url.query_pairs_mut() /// .clear() /// .append_pair("foo", "bar & baz") /// .append_pair("saisons", "Été+hiver"); @@ -658,11 +658,11 @@ impl Url { /// "https://example.net/?foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver#nav"); /// ``` /// - /// Note: `url.mutate_query_pairs().clear();` is equivalent to `url.set_query(Some(""))`, + /// Note: `url.query_pairs_mut().clear();` is equivalent to `url.set_query(Some(""))`, /// not `url.set_query(None)`. /// /// The state of `Url` is unspecified if this return value is leaked without being dropped. - pub fn mutate_query_pairs(&mut self) -> form_urlencoded::Serializer { + pub fn query_pairs_mut(&mut self) -> form_urlencoded::Serializer { let fragment = self.take_fragment(); let query_start; @@ -1361,7 +1361,7 @@ fn io_error(reason: &str) -> io::Result { Err(io::Error::new(io::ErrorKind::InvalidData, reason)) } -/// Implementation detail of `Url::mutate_query_pairs`. Typically not used directly. +/// Implementation detail of `Url::query_pairs_mut`. Typically not used directly. pub struct UrlQuery<'a> { url: &'a mut Url, fragment: Option, From e185a8634cc2a7db1e4e7448ac6c3734547b10dc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 21 Apr 2016 23:06:42 +0200 Subject: [PATCH 2/2] Make pop_path_segment and push_path_segment private for now. See https://github.com/servo/rust-url/issues/188 --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9d410efe..121383f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -715,7 +715,8 @@ impl Url { /// /// If this URL is cannot-be-a-base, do nothing and return `Err`. /// If this URL is not cannot-be-a-base and its path is `/`, do nothing and return `Ok`. - pub fn pop_path_segment(&mut self) -> Result<(), ()> { + // Temporarily private: https://github.com/servo/rust-url/issues/188 + /*pub*/ fn pop_path_segment(&mut self) -> Result<(), ()> { if self.cannot_be_a_base() { return Err(()) } @@ -741,7 +742,8 @@ impl Url { /// Add a segment at the end of this URL’s path. /// /// If this URL is cannot-be-a-base, do nothing and return `Err`. - pub fn push_path_segment(&mut self, segment: &str) -> Result<(), ()> { + // Temporarily private: https://github.com/servo/rust-url/issues/188 + /*pub*/ fn push_path_segment(&mut self, segment: &str) -> Result<(), ()> { if self.cannot_be_a_base() { return Err(()) }