cargo fmt

master
Jos van den Oever 2019-01-22 00:03:50 +01:00
parent 1e4d769b32
commit ad94fb1036
5 changed files with 19 additions and 13 deletions

View File

@ -11,13 +11,15 @@ fn main() {
Arg::with_name("overwrite-implementation") Arg::with_name("overwrite-implementation")
.long("overwrite-implementation") .long("overwrite-implementation")
.help("Overwrite existing implementation."), .help("Overwrite existing implementation."),
).arg( )
.arg(
Arg::with_name("config") Arg::with_name("config")
.multiple(true) .multiple(true)
.required(true) .required(true)
.takes_value(true) .takes_value(true)
.help("Configuration file(s)"), .help("Configuration file(s)"),
).get_matches(); )
.get_matches();
let overwrite_implementation = matches.is_present("overwrite-implementation"); let overwrite_implementation = matches.is_present("overwrite-implementation");
for config in matches.values_of("config").unwrap() { for config in matches.values_of("config").unwrap() {

View File

@ -1,11 +1,11 @@
use configuration_private::*; use configuration_private::*;
use serde_json; use serde_json;
use toml;
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::error::Error; use std::error::Error;
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::rc::Rc; use std::rc::Rc;
use toml;
mod json { mod json {
use super::Rust; use super::Rust;
@ -61,7 +61,7 @@ mod json {
pub enum RustEdition { pub enum RustEdition {
Rust2015, Rust2015,
Rust2018, Rust2018,
Unknown Unknown,
} }
impl<'a> ::std::convert::From<Option<&'a str>> for RustEdition { impl<'a> ::std::convert::From<Option<&'a str>> for RustEdition {
@ -471,7 +471,10 @@ fn post_process(config_file: &Path, json: json::Config) -> Result<Config, Box<Er
buf.pop(); buf.pop();
buf.push("Cargo.toml"); buf.push("Cargo.toml");
let manifest: toml::Value = fs::read_to_string(&buf)?.parse()?; let manifest: toml::Value = fs::read_to_string(&buf)?.parse()?;
manifest["package"].get("edition").and_then(|val| val.as_str()).into() manifest["package"]
.get("edition")
.and_then(|val| val.as_str())
.into()
}; };
Ok(Config { Ok(Config {

View File

@ -149,7 +149,8 @@ private:"
"QVariant" "QVariant"
} else { } else {
p.type_name() p.type_name()
}.to_string(); }
.to_string();
if p.is_object() { if p.is_object() {
t.push_str("*"); t.push_str("*");
} }
@ -213,7 +214,7 @@ public:
fn is_column_write(o: &Object, col: usize) -> bool { fn is_column_write(o: &Object, col: usize) -> bool {
o.item_properties o.item_properties
.values() .values()
.any(|ip|ip.write && (col == 0 || (ip.roles.len() > col && !ip.roles[col].is_empty()))) .any(|ip| ip.write && (col == 0 || (ip.roles.len() > col && !ip.roles[col].is_empty())))
} }
fn write_function_c_decl( fn write_function_c_decl(

View File

@ -12,14 +12,12 @@ mod cpp;
mod rust; mod rust;
mod util; mod util;
use configuration::Config;
use std::error::Error; use std::error::Error;
use std::path::Path; use std::path::Path;
use configuration::Config;
/// Read a file with bindings. /// Read a file with bindings.
pub fn read_bindings_file<P: AsRef<Path>>( pub fn read_bindings_file<P: AsRef<Path>>(config_file: P) -> Result<Config, Box<Error>> {
config_file: P,
) -> Result<Config, Box<Error>> {
configuration::parse(config_file) configuration::parse(config_file)
} }

View File

@ -335,7 +335,9 @@ impl {0}Emitter {{
/// reference. That is undefined behaviour and forbidden. /// reference. That is undefined behaviour and forbidden.
pub fn clone(&mut self) -> {0}Emitter {{ pub fn clone(&mut self) -> {0}Emitter {{
{0}Emitter {{ {0}Emitter {{
qobject: self.qobject.clone(),", o.name)?; qobject: self.qobject.clone(),",
o.name
)?;
for (name, p) in &o.properties { for (name, p) in &o.properties {
if p.is_object() { if p.is_object() {
continue; continue;
@ -1540,6 +1542,6 @@ use {}{}::*;
fn get_module_prefix(conf: &Config) -> &'static str { fn get_module_prefix(conf: &Config) -> &'static str {
match conf.rust_edition { match conf.rust_edition {
RustEdition::Rust2018 => "crate::", RustEdition::Rust2018 => "crate::",
_ => "" _ => "",
} }
} }