Enforce rust naming conventions

This commit is contained in:
Sudarsan Balaji 2022-04-04 10:58:01 +01:00
parent d72905168b
commit a5bd16db4d
No known key found for this signature in database
GPG Key ID: 6644FFAC82AC1970

View File

@ -6,17 +6,17 @@ use uniffi_bindgen;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum Language { pub enum Language {
KOTLIN, Kotlin,
PYTHON, Python,
SWIFT, Swift,
} }
impl fmt::Display for Language { impl fmt::Display for Language {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
Language::KOTLIN => write!(f, "kotlin"), Language::Kotlin => write!(f, "kotlin"),
Language::SWIFT => write!(f, "swift"), Language::Swift => write!(f, "swift"),
Language::PYTHON => write!(f, "python"), Language::Python => write!(f, "python"),
} }
} }
} }
@ -36,9 +36,9 @@ impl FromStr for Language {
type Err = Error; type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match s { match s {
"kotlin" => Ok(Language::KOTLIN), "kotlin" => Ok(Language::Kotlin),
"python" => Ok(Language::PYTHON), "python" => Ok(Language::Python),
"swift" => Ok(Language::SWIFT), "swift" => Ok(Language::Swift),
_ => Err(Error::UnsupportedLanguage), _ => Err(Error::UnsupportedLanguage),
} }
} }
@ -126,7 +126,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
generate_bindings(&opt)?; generate_bindings(&opt)?;
if opt.language == Language::PYTHON { if opt.language == Language::Python {
if let Some(path) = opt.python_fixup_path { if let Some(path) = opt.python_fixup_path {
println!("Fixing up python lib path, {:?}", &path); println!("Fixing up python lib path, {:?}", &path);
fixup_python_lib_path(&opt.out_dir, &path)?; fixup_python_lib_path(&opt.out_dir, &path)?;