Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
vodik committed Sep 17, 2021
1 parent be30815 commit c7a6a1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions ext-php-rs-derive/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ pub fn parser(args: AttributeArgs, input: ItemImpl) -> Result<TokenStream> {
}
}
syn::ImplItem::Method(mut method) => {
let (sig, method) = method::parser(&mut method, args.rename_methods.unwrap_or(RenameRule::Camel))?;
let (sig, method) = method::parser(
&mut method,
args.rename_methods.unwrap_or(RenameRule::Camel),
)?;
class.methods.push(method);
sig
}
Expand Down Expand Up @@ -207,9 +210,7 @@ mod tests {

#[test]
fn test_rename_php_methods() {
for &(original, camel, snake) in &[
("get_name", "getName", "get_name"),
] {
for &(original, camel, snake) in &[("get_name", "getName", "get_name")] {
assert_eq!(camel, RenameRule::Camel.rename(original));
assert_eq!(snake, RenameRule::Snake.rename(original));
}
Expand Down
12 changes: 9 additions & 3 deletions ext-php-rs-derive/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use anyhow::{anyhow, bail, Result};
use quote::ToTokens;
use std::collections::HashMap;

use crate::{function, impl_::{ParsedAttribute, RenameRule, Visibility, parse_attribute}};
use crate::{
function,
impl_::{parse_attribute, ParsedAttribute, RenameRule, Visibility},
};
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::{punctuated::Punctuated, FnArg, ImplItemMethod, Lit, Pat, Signature, Token, Type};
Expand Down Expand Up @@ -31,7 +34,10 @@ pub struct Method {
pub visibility: Visibility,
}

pub fn parser(input: &mut ImplItemMethod, rename_rule: RenameRule) -> Result<(TokenStream, Method)> {
pub fn parser(
input: &mut ImplItemMethod,
rename_rule: RenameRule,
) -> Result<(TokenStream, Method)> {
let mut defaults = HashMap::new();
let mut optional = None;
let mut visibility = Visibility::Public;
Expand Down Expand Up @@ -93,7 +99,7 @@ pub fn parser(input: &mut ImplItemMethod, rename_rule: RenameRule) -> Result<(To

let name = identifier.unwrap_or_else(|| rename_rule.rename(ident.to_string()));
let method = Method {
name,
name,
ident: internal_ident.to_string(),
args,
optional,
Expand Down

0 comments on commit c7a6a1a

Please sign in to comment.