Skip to main content

latest_from_index

Function latest_from_index 

Source
pub fn latest_from_index(body: &str) -> Option<String>
Expand description

The highest non-yanked version in a sparse-index document (one JSON object per line). Lines that don’t parse, lack a vers, or are yanked are skipped; None means nothing usable was found.

use coding_tools::update::latest_from_index;
let body = r#"{"name":"x","vers":"0.8.3","yanked":false}
{"name":"x","vers":"0.9.0","yanked":false}
{"name":"x","vers":"0.10.0","yanked":true}"#;
assert_eq!(latest_from_index(body).as_deref(), Some("0.9.0"));