Parse raw channel strings as well.

This commit is contained in:
Sergio Benitez 2021-03-16 17:32:37 -07:00
parent 2f9b700d82
commit e7f0ff4d91

View File

@ -54,11 +54,12 @@ impl Channel {
/// assert!(stable.is_stable());
/// ```
pub fn parse(version: &str) -> Option<Channel> {
if version.contains("-dev") {
let version = version.trim();
if version.contains("-dev") || version == "dev" {
Some(Channel(Kind::Dev))
} else if version.contains("-nightly") {
} else if version.contains("-nightly") || version == "nightly" {
Some(Channel(Kind::Nightly))
} else if version.contains("-beta") {
} else if version.contains("-beta") || version == "beta" {
Some(Channel(Kind::Beta))
} else if !version.contains("-") {
Some(Channel(Kind::Stable))