Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Fix deserialize type bounds
Browse files Browse the repository at this point in the history
So that types requiring borrowed data cannot be deserialized from docopt
  • Loading branch information
lawliet89 authored and BurntSushi committed Jul 11, 2017
1 parent 9c66de7 commit 62cf32b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ impl Docopt {
///
/// For details on how decoding works, please see the documentation for
/// `ArgvMap`.
pub fn deserialize<'a, 'de: 'a, D>(&'a self) -> Result<D>
where D: de::Deserialize<'de>
pub fn deserialize<D>(&self) -> Result<D>
where D: de::DeserializeOwned
{
self.parse().and_then(|vals| vals.deserialize())
}
Expand Down Expand Up @@ -392,7 +392,7 @@ impl ArgvMap {
///
/// In this example, only the `bool` type was used, but any type satisfying
/// the `Deserialize` trait is valid.
pub fn deserialize<'de, T: de::Deserialize<'de>>(self) -> Result<T> {
pub fn deserialize<T: de::DeserializeOwned>(self) -> Result<T> {
de::Deserialize::deserialize(&mut Deserializer {
vals: self,
stack: vec![],
Expand Down Expand Up @@ -641,9 +641,9 @@ impl Value {
/// extern crate serde;
/// # fn main() {
/// use docopt::Docopt;
/// use serde::de::Deserialize;
/// use serde::de::DeserializeOwned;
///
/// fn deserialize<'de, D: Deserialize<'de>>(usage: &str, argv: &[&str])
/// fn deserialize<D: DeserializeOwned>(usage: &str, argv: &[&str])
/// -> Result<D, docopt::Error> {
/// Docopt::new(usage)
/// .and_then(|d| d.argv(argv.iter()).deserialize())
Expand Down

0 comments on commit 62cf32b

Please sign in to comment.