cargo/util/toml_mut/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Utilities for in-place editing of Cargo.toml manifests.
//!
//! These utilities operate only on the level of a TOML document, and generally
//! do not perform any processing of information beyond what is required for
//! editing. For more comprehensive usage of manifests, see
//! [`Manifest`](crate::core::manifest::Manifest).
//!
//! In most cases, the entrypoint for editing is
//! [`LocalManifest`](crate::util::toml_mut::manifest::LocalManifest),
//! which contains editing functionality for a given manifest's dependencies.

pub mod dependency;
pub mod manifest;
pub mod upgrade;

// Based on Iterator::is_sorted from nightly std; remove in favor of that when stabilized.
pub fn is_sorted(mut it: impl Iterator<Item = impl PartialOrd>) -> bool {
    let Some(mut last) = it.next() else {
        return true;
    };

    for curr in it {
        if curr < last {
            return false;
        }
        last = curr;
    }

    true
}