Changeset View
Changeset View
Standalone View
Standalone View
src/configuration.rs
Context not available. | |||||
5 | use std::fs; | 5 | use std::fs; | ||
---|---|---|---|---|---|
6 | use std::path::{Path, PathBuf}; | 6 | use std::path::{Path, PathBuf}; | ||
7 | use std::rc::Rc; | 7 | use std::rc::Rc; | ||
8 | use toml; | | |||
9 | 8 | | |||
10 | mod json { | 9 | mod json { | ||
11 | use super::Rust; | 10 | use super::Rust; | ||
Context not available. | |||||
466 | post_process_object(object, &mut objects, &json.objects)?; | 465 | post_process_object(object, &mut objects, &json.objects)?; | ||
467 | } | 466 | } | ||
468 | 467 | | |||
469 | let rust_edition: RustEdition = { | | |||
470 | let mut buf = config_file.to_path_buf(); | | |||
471 | buf.pop(); | | |||
472 | buf.push(&json.rust.dir); | | |||
473 | buf.push("Cargo.toml"); | | |||
474 | if !buf.exists() { | | |||
475 | return Err(format!("{} does not exist.", buf.display()).into()); | | |||
476 | } | | |||
477 | let manifest: toml::Value = fs::read_to_string(&buf)?.parse()?; | | |||
478 | manifest["package"] | | |||
479 | .get("edition") | | |||
480 | .and_then(|val| val.as_str()) | | |||
481 | .into() | | |||
482 | }; | | |||
483 | | ||||
484 | Ok(Config { | 468 | Ok(Config { | ||
485 | config_file: config_file.into(), | 469 | config_file: config_file.into(), | ||
486 | cpp_file: json.cpp_file, | 470 | cpp_file: json.cpp_file, | ||
487 | objects, | 471 | objects, | ||
488 | rust: json.rust, | 472 | rust: json.rust, | ||
489 | rust_edition, | 473 | rust_edition: RustEdition::Rust2015, | ||
490 | overwrite_implementation: json.overwrite_implementation, | 474 | overwrite_implementation: json.overwrite_implementation, | ||
491 | }) | 475 | }) | ||
492 | } | 476 | } | ||
Context not available. |