fn from_str(version_string: &str) -> Result<Self, Self::Err> {
        let mut pairs: Vec<(Version, Version)> = Vec::new();
        let pieces: ::std::str::Split<char> = version_string.trim().split(',');

        for piece in pieces {
            let p: &str = piece.trim();

            if p.is_empty() {
                continue;
            } else if p.contains('-') {
                let mut pair = p.split('-');

                let low  = pair.next().ok_or(ProtoverError::Unparseable)?;
                let high = pair.next().ok_or(ProtoverError::Unparseable)?;

                let lo: Version =  low.parse().or(Err(ProtoverError::Unparseable))?;
                let hi: Version = high.parse().or(Err(ProtoverError::Unparseable))?;

                if lo == u32::MAX || hi == u32::MAX {
                    return Err(ProtoverError::ExceedsMax);
                }
                pairs.push((lo, hi));
            } else {
                let v: u32 = p.parse().or(Err(ProtoverError::Unparseable))?;

                if v == u32::MAX {
                    return Err(ProtoverError::ExceedsMax);
                }
                pairs.push((v, v));
            }
        }
        // If we were passed in an empty string, or a bunch of whitespace, or
        // simply a comma, or a pile of commas, then return an empty ProtoSet.
        if pairs.len() == 0 {
            return Ok(ProtoSet::default());
        }
        ProtoSet::from_slice(&pairs[..])
    }
/// Parse the unique version numbers supported by a subprotocol from a string.
///
/// # Inputs
///
/// * `version_string`, a string comprised of "[0-9,-]"
///
/// # Returns
///
/// A `Result` whose `Ok` value is a `ProtoSet` holding all of the unique
/// version numbers.
///
/// The returned `Result`'s `Err` value is an `ProtoverError` appropriate to
/// the error.
///
/// # Errors
///
/// This function will error if:
///
/// * the `version_string` is an equals (`"="`) sign,
/// * the expansion of a version range produces an error (see
///   `expand_version_range`),
/// * any single version number is not parseable as an `u32` in radix 10, or
/// * there are greater than 2^16 version numbers to expand.
///
/// # Examples
/// 
/// ```
/// use std::str::FromStr;
///
/// use protover::errors::ProtoverError;
/// use protover::protoset::ProtoSet;
///
/// # fn do_test() -> Result<ProtoSet, ProtoverError> {
/// let protoset: ProtoSet = ProtoSet::from_str("2-5,8")?;
///
/// assert!(protoset.contains(&5));
/// assert!(!protoset.contains(&10));
///
/// // We can also equivalently call `ProtoSet::from_str` by doing (all
/// // implementations of `FromStr` can be called this way, this one isn't
/// // special):
/// let protoset: ProtoSet = "4-6,12".parse()?;
///
/// // Calling it (either way) can take really large ranges (up to `u32::MAX`):
/// let protoset: ProtoSet = "1-70000".parse()?;
/// let protoset: ProtoSet = "1-4294967296".parse()?;
///
/// // There are lots of ways to get an `Err` from this function.  Here are
/// // a few:
/// assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("="));
/// assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("-"));
/// assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("not_an_int"));
/// assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("3-"));
/// assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1-,4"));
///
/// // Things which would get parsed into an _empty_ `ProtoSet` are,
/// // however, legal, and result in an empty `ProtoSet`:
/// assert_eq!(Ok(ProtoSet::default()), ProtoSet::from_str(""));
/// assert_eq!(Ok(ProtoSet::default()), ProtoSet::from_str(",,,"));
/// #
/// # Ok(protoset)
/// # }
/// # fn main() { do_test(); }  // wrap the test so we can use the ? operator
/// ```
Parse the unique version numbers supported by a subprotocol from a string.
Parse the unique version numbers supported by a subprotocol from a string .
fn from_str(version_string: &str) -> Result<Self, Self::Err> {
        let mut pairs: Vec<(Version, Version)> = Vec::new();
        let pieces: ::std::str::Split<char> = version_string.trim().split(',');
        for piece in pieces {
            let p: &str = piece.trim();
            if p.is_empty() {
                continue;
            } else if p.contains('-') {
                let mut pair = p.split('-');
                let low  = pair.next().ok_or(ProtoverError::Unparseable)?;
                let high = pair.next().ok_or(ProtoverError::Unparseable)?;
                let lo: Version =  low.parse().or(Err(ProtoverError::Unparseable))?;
                let hi: Version = high.parse().or(Err(ProtoverError::Unparseable))?;
                if lo == u32::MAX || hi == u32::MAX {
                    return Err(ProtoverError::ExceedsMax);
                }
                pairs.push((lo, hi));
            } else {
                let v: u32 = p.parse().or(Err(ProtoverError::Unparseable))?;
                if v == u32::MAX {
                    return Err(ProtoverError::ExceedsMax);
                }
                pairs.push((v, v));
            }
        }
        // If we were passed in an empty string, or a bunch of whitespace, or
        // simply a comma, or a pile of commas, then return an empty ProtoSet.
        if pairs.len() == 0 {
            return Ok(ProtoSet::default());
        }
        ProtoSet::from_slice(&pairs[..])
    }
fn from_str ( version_string : & str ) -> Result < Self , Self :: Err > { let mut pairs : Vec < ( Version , Version ) > = Vec :: new ( ) ; let pieces : :: std :: str :: Split < char > = version_string . trim ( ) . split ( ',' ) ; for piece in pieces { let p : & str = piece . trim ( ) ; if p . is_empty ( ) { continue ; } else if p . contains ( '-' ) { let mut pair = p . split ( '-' ) ; let low = pair . next ( ) . ok_or ( ProtoverError :: Unparseable ) ? ; let high = pair . next ( ) . ok_or ( ProtoverError :: Unparseable ) ? ; let lo : Version = low . parse ( ) . or ( Err ( ProtoverError :: Unparseable ) ) ? ; let hi : Version = high . parse ( ) . or ( Err ( ProtoverError :: Unparseable ) ) ? ; if lo == u32 :: MAX || hi == u32 :: MAX { return Err ( ProtoverError :: ExceedsMax ) ; } pairs . push ( ( lo , hi ) ) ; } else { let v : u32 = p . parse ( ) . or ( Err ( ProtoverError :: Unparseable ) ) ? ; if v == u32 :: MAX { return Err ( ProtoverError :: ExceedsMax ) ; } pairs . push ( ( v , v ) ) ; } } // If we were passed in an empty string, or a bunch of whitespace, or // simply a comma, or a pile of commas, then return an empty ProtoSet. if pairs . len ( ) == 0 { return Ok ( ProtoSet :: default ( ) ) ; } ProtoSet :: from_slice ( & pairs [ .. ] ) }
Parse the unique version numbers supported by a subprotocol from a string.
Parse the unique version numbers supported by a subprotocol from a string .
version_string
&str
A `Result` whose `Ok` value is a `ProtoSet` holding all of the unique
version numbers.

The returned `Result`'s `Err` value is an `ProtoverError` appropriate to
the error.
A ` Result ` whose ` Ok ` value is a ` ProtoSet ` holding all of the unique version numbers . The returned ` Result ` ' s ` Err ` value is an ` ProtoverError ` appropriate to the error .
version_string
&str
inputs
`version_string`, a string comprised of "[0-9,-]"
` version_string ` a string comprised of " [ 0 - 9 - ] "
errors
This function will error if.

the `version_string` is an equals (`"="`) sign,
the expansion of a version range produces an error (see
`expand_version_range`),
any single version number is not parseable as an `u32` in radix 10, or
there are greater than 2^16 version numbers to expand.
This function will error if . the ` version_string ` is an equals ( ` " = " ` ) sign the expansion of a version range produces an error ( see ` expand_version_range ` ) any single version number is not parseable as an ` u32 ` in radix 10 or there are greater than 2^16 version numbers to expand .
examples
```
use std::str::FromStr.

use protover::errors::ProtoverError;
use protover::protoset::ProtoSet.
` ` ` use std :: str :: FromStr . use protover :: errors :: ProtoverError ; use protover :: protoset :: ProtoSet .
fn do_test() -> result<protoset, protovererror> {
let protoset: ProtoSet = ProtoSet::from_str("2-5,8")?.

assert!(protoset.contains(&5));
assert!(!protoset.contains(&10)).

We can also equivalently call `ProtoSet::from_str` by doing (all
implementations of `FromStr` can be called this way, this one isn't
special):
let protoset: ProtoSet = "4-6,12".parse()?.

Calling it (either way) can take really large ranges (up to `u32::MAX`):
let protoset: ProtoSet = "1-70000".parse()?;
let protoset: ProtoSet = "1-4294967296".parse()?.

There are lots of ways to get an `Err` from this function.  Here are
a few:
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("="));
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("-"));
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("not_an_int"));
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("3-"));
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1-,4")).

Things which would get parsed into an _empty_ `ProtoSet` are,
however, legal, and result in an empty `ProtoSet`:
assert_eq!(Ok(ProtoSet::default()), ProtoSet::from_str(""));
assert_eq!(Ok(ProtoSet::default()), ProtoSet::from_str(",,,")).
let protoset : ProtoSet = ProtoSet :: from_str ( " 2 - 5 8 " ) ? . assert! ( protoset . contains ( &5 )) ; assert! ( !protoset . contains ( &10 )) . We can also equivalently call ` ProtoSet :: from_str ` by doing ( all implementations of ` FromStr ` can be called this way this one isn ' t special ) : let protoset : ProtoSet = " 4 - 6 12 " . parse () ? . Calling it ( either way ) can take really large ranges ( up to ` u32 :: MAX ` ) : let protoset : ProtoSet = " 1 - 70000 " . parse () ? ; let protoset : ProtoSet = " 1 - 4294967296 " . parse () ? . There are lots of ways to get an ` Err ` from this function . Here are a few : assert_eq! ( Err ( ProtoverError :: Unparseable ) ProtoSet :: from_str ( " = " )) ; assert_eq! ( Err ( ProtoverError :: Unparseable ) ProtoSet :: from_str ( " - " )) ; assert_eq! ( Err ( ProtoverError :: Unparseable ) ProtoSet :: from_str ( " not_an_int " )) ; assert_eq! ( Err ( ProtoverError :: Unparseable ) ProtoSet :: from_str ( " 3 - " )) ; assert_eq! ( Err ( ProtoverError :: Unparseable ) ProtoSet :: from_str ( " 1 - 4 " )) . Things which would get parsed into an _empty_ ` ProtoSet ` are however legal and result in an empty ` ProtoSet ` : assert_eq! ( Ok ( ProtoSet :: default () ) ProtoSet :: from_str ( " " )) ; assert_eq! ( Ok ( ProtoSet :: default () ) ProtoSet :: from_str ( " " )) .
ok(protoset)
None
}
None
fn main() { do_test(); }  // wrap the test so we can use the ? operator
None