From d1c6d4b0198299843406b6b3d825faa0f09ac1cf Mon Sep 17 00:00:00 2001 From: Antun Horvat Date: Tue, 24 Sep 2024 17:07:26 +0200 Subject: [PATCH] Formatting applied --- src/analysis/imports.rs | 2 +- src/analysis/rust_type.rs | 2 +- src/codegen/bound.rs | 2 +- src/codegen/enums.rs | 2 +- src/codegen/flags.rs | 7 ++++--- src/nameutil.rs | 3 +-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/analysis/imports.rs b/src/analysis/imports.rs index 0a5baca98..2a298c566 100644 --- a/src/analysis/imports.rs +++ b/src/analysis/imports.rs @@ -7,8 +7,8 @@ use std::{ }; use super::namespaces; -use crate::{library::Library, nameutil::crate_name, version::Version}; use crate::nameutil::mangle_crate; +use crate::{library::Library, nameutil::crate_name, version::Version}; fn is_first_char_up(s: &str) -> bool { s.chars().next().unwrap().is_uppercase() diff --git a/src/analysis/rust_type.rs b/src/analysis/rust_type.rs index 7d38ed5fe..a01fd60f8 100644 --- a/src/analysis/rust_type.rs +++ b/src/analysis/rust_type.rs @@ -1,6 +1,7 @@ use std::{borrow::Borrow, result}; use super::conversion_type::ConversionType; +use crate::nameutil::escape_digit; use crate::{ analysis::{record_type::RecordType, ref_mode::RefMode, try_from_glib::TryFromGlib}, config::functions::{CallbackParameter, CallbackParameters}, @@ -9,7 +10,6 @@ use crate::{ nameutil::{is_gstring, use_glib_type}, traits::*, }; -use crate::nameutil::escape_digit; #[derive(Clone, Debug, PartialEq, Eq)] pub enum TypeError { diff --git a/src/codegen/bound.rs b/src/codegen/bound.rs index 8a4407043..915df17e6 100644 --- a/src/codegen/bound.rs +++ b/src/codegen/bound.rs @@ -1,3 +1,4 @@ +use crate::nameutil::escape_digit; use crate::{ analysis::{ bounds::{Bound, BoundType}, @@ -5,7 +6,6 @@ use crate::{ }, library::Nullable, }; -use crate::nameutil::escape_digit; impl Bound { /// Returns the type parameter reference. diff --git a/src/codegen/enums.rs b/src/codegen/enums.rs index 800e29b2f..3ed0bb9c4 100644 --- a/src/codegen/enums.rs +++ b/src/codegen/enums.rs @@ -143,7 +143,7 @@ fn generate_enum( } doc_alias(w, &enum_.c_type, "", 0)?; - writeln!(w, "{} enum {} {{", analysis.visibility, &enum_name )?; + writeln!(w, "{} enum {} {{", analysis.visibility, &enum_name)?; for member in &members { cfg_deprecated( w, diff --git a/src/codegen/flags.rs b/src/codegen/flags.rs index a63341d60..856955482 100644 --- a/src/codegen/flags.rs +++ b/src/codegen/flags.rs @@ -4,6 +4,7 @@ use std::{ }; use super::{function, general::allow_deprecated, trait_impls}; +use crate::nameutil::flag_name; use crate::{ analysis::flags::Info, codegen::{ @@ -21,7 +22,6 @@ use crate::{ nameutil::{bitfield_member_name, use_glib_type}, traits::*, }; -use crate::nameutil::flag_name; pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec) { if !env @@ -60,7 +60,7 @@ pub fn generate(env: &Env, root_path: &Path, mod_rs: &mut Vec) { .map(|_| "#[allow(deprecated)]\n") .unwrap_or(""), flags_analysis.visibility.export_visibility(), - flag_name( &flags.name ) + flag_name(&flags.name) )); generate_flags(env, w, flags, config, flags_analysis)?; } @@ -103,7 +103,8 @@ fn generate_flags( writeln!( w, " {} struct {}: u32 {{", - analysis.visibility, flag_name(&flags.name) + analysis.visibility, + flag_name(&flags.name) )?; for member in &flags.members { let member_config = config.members.matched(&member.name); diff --git a/src/nameutil.rs b/src/nameutil.rs index 52ab97d59..9c4e954d3 100644 --- a/src/nameutil.rs +++ b/src/nameutil.rs @@ -77,9 +77,8 @@ pub fn module_name(name: &str) -> String { pub fn mangle_crate(name: &str) -> String { let parts: Vec<_> = name.split("::").collect(); let name = if let Some(name) = parts.iter().last() { - let new_name = if name.starts_with(char::is_numeric) { - format!("_{name}") + format!("_{name}") } else { name.to_string() };