browserslist_data/
electron.rs1use std::ops::Range;
2
3include!("generated/electron-to-chromium.rs");
4
5pub fn versions() -> impl ExactSizeIterator<Item = (f32, &'static str)> + DoubleEndedIterator {
6 ELECTRON_VERSIONS
7 .iter()
8 .copied()
9 .zip(CHROMIUM_VERSIONS.iter().copied())
10}
11
12pub fn get(electron_version: f32) -> Option<&'static str> {
13 let index = ELECTRON_VERSIONS
14 .binary_search_by(|probe| probe.total_cmp(&electron_version))
15 .ok()?;
16 CHROMIUM_VERSIONS.get(index).copied()
17}
18
19pub fn bounded_range(range: Range<f32>) -> Result<&'static [&'static str], f32> {
20 let start = ELECTRON_VERSIONS
21 .binary_search_by(|probe| probe.total_cmp(&range.start))
22 .map_err(|_| range.start)?;
23 let end = ELECTRON_VERSIONS
24 .binary_search_by(|probe| probe.total_cmp(&range.end))
25 .map_err(|_| range.end)?;
26
27 Ok(&CHROMIUM_VERSIONS[start..=end])
28}