Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
Add Value::take
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed May 28, 2020
1 parent 5422332 commit 7cc0cd7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod ser;

use std::cmp::{Ord, Ordering, PartialOrd};
use std::collections::BTreeMap;
use std::mem;

#[doc(inline)]
pub use self::de::from_value;
Expand Down Expand Up @@ -321,4 +322,9 @@ impl Value {
_ => None,
}
}

/// Take the [Value], leaving [Null] in place.
pub fn take(&mut self) -> Value {
mem::replace(self, Value::Null)
}
}

0 comments on commit 7cc0cd7

Please sign in to comment.