From b4a5ff563bf3ab6f1c83b5c79e625ff0292aa480 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 18 Apr 2018 02:09:23 +0300 Subject: [PATCH 1/5] Channel: Add items_owned() method This allows to consume the `Channel` and get the owned vector/slice of `Items`. This can avoid the reallocation/clone of the whole Items slice in situations where you need to pass the owenership of the data, like when using futures. --- src/channel.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/channel.rs b/src/channel.rs index 87c98a89ff..2141867882 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -716,6 +716,21 @@ impl Channel { &mut self.items } + /// Consume the `Channel` and return a Vector of owned `Item`s. + /// + /// # Examples + /// + /// ``` + /// use rss::{Channel, Item}; + /// + /// let mut channel = Channel::default(); + /// channel.set_items(vec![Item::default()]); + /// assert_eq!(channel.items_owned().len(), 1); + /// ``` + pub fn items_owned(self) -> Vec { + self.items + } + /// Set the items in this channel. /// /// # Examples From 2b42f26f3d0c2855f5af6650490e8741d4449ace Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 18 Apr 2018 13:40:16 +0900 Subject: [PATCH 2/5] Rename items_owned method, tweak docs. --- src/channel.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/channel.rs b/src/channel.rs index 2141867882..2af8c5592b 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -716,7 +716,7 @@ impl Channel { &mut self.items } - /// Consume the `Channel` and return a Vector of owned `Item`s. + /// Consume the `Channel` and return a vector of `Item`s. /// /// # Examples /// @@ -725,9 +725,9 @@ impl Channel { /// /// let mut channel = Channel::default(); /// channel.set_items(vec![Item::default()]); - /// assert_eq!(channel.items_owned().len(), 1); + /// assert_eq!(channel.into_items().len(), 1); /// ``` - pub fn items_owned(self) -> Vec { + pub fn into_items(self) -> Vec { self.items } From 48f16af4b35396205a523cb80550d27779d358d2 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 18 Apr 2018 14:08:28 +0900 Subject: [PATCH 3/5] Test in release mode. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58bda45fe6..7e523ec7e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ before_script: script: - | travis-cargo --only nighlty fmt -- --write-mode=diff && - cargo build --features "from_url serde validation" && - cargo test --features "from_url serde validation" && + cargo build --release --features "from_url serde validation" && + cargo test --release --features "from_url serde validation" && travis-cargo --only stable doc -- --features "from_url validation serde" after_success: From 35c838b80262074f5db836150388a8dabf5b0089 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 18 Apr 2018 14:42:14 +0900 Subject: [PATCH 4/5] Allow failures on nightly. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7e523ec7e9..e6fe6975bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ rust: - beta - stable +allow_failures: + - nightly + before_script: - export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH - pip install -v 'travis-cargo<0.2' --user From 3ae859f6cb3e7214b652365a6799eccf322f36ef Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 18 Apr 2018 14:56:42 +0900 Subject: [PATCH 5/5] Correct Travis config. --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6fe6975bf..07c179f203 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,9 @@ rust: - beta - stable -allow_failures: - - nightly +matrix: + allow_failures: + - rust: nightly before_script: - export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH