Crates.io | opam-file-rs |
lib.rs | opam-file-rs |
version | 0.1.5 |
source | src |
created_at | 2021-02-15 15:55:08.879086 |
updated_at | 2021-06-03 14:14:01.068945 |
description | Parser and printer for the opam file syntax with Rust |
homepage | |
repository | https://github.com/puripuri2100/opam-file-rs |
max_upload_size | |
id | 355585 |
size | 35,148 |
Parse OPAM file.
use opam_file_rs;
fn main () {
let opam = r#"
opam-version: "2.0"
version: "0.1.0"
name: "opam-file-rs"
dev-repo: "git+https://github.com/puripuri2100/opam-file-rs"
license: "MIT"
maintainer: "Naoki Kaneko <puripuri2100@gmail.com>"
depends: [
"lalrpop-util" {>= "0.19.4"}
"thiserror" {>= "1.0.23"}
]
"#;
assert!(opam_file_rs::parse(opam).is_ok());
}
A data structure can be converted to an OPAM file format by value::format_opam_file
.
use opam_file_rs;
fn main() {
let opam_str = r#"
opam-version: "2.0"
version: "0.1.0"
name: "opam-file-rs"
dev-repo: "git+https://github.com/puripuri2100/opam-file-rs"
license: "MIT"
maintainer: "Naoki Kaneko <puripuri2100@gmail.com>"
depends: [
"lalrpop-util" {>= "0.19.4"}
"thiserror" {>= "1.0.23"}
]
"#;
let opam = opam_file_rs::parse(opam_str).unwrap();
println!("{}", opam_file_rs::value::format_opam_file(opam));
}
(c) 2021 Naoki Kaneko (a.k.a. "puripuri2100")