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
use cargo_toml::Value;

/// Get a copy of the `rust-toolchain.toml` file used by the Rune project
/// itself.
pub fn rust_toolchain() -> Value {
    toml::toml! {
        [toolchain]
        channel = "nightly-2022-02-27"
        targets = ["wasm32-unknown-unknown"]
        components = ["rustfmt"]
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn generated_toolchain_file_is_always_in_sync_with_repo() {
        let original = include_str!("../../../rust-toolchain.toml");
        let original: Value = toml::from_str(original).unwrap();

        let got = rust_toolchain();

        assert_eq!(got, original);
    }
}