Skip to content

Commit

Permalink
Fix a lang nix with function edge case (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
whs-dot-hk authored Nov 9, 2024
1 parent b376f2a commit 12c24ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/fmt/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl<'a> Formatter<'a> {
}
}

impl<'a> std::fmt::Write for Formatter<'a> {
impl std::fmt::Write for Formatter<'_> {
fn write_str(&mut self, s: &str) -> fmt::Result {
if !s.is_empty() {
Formatter::write_str(self, s)?;
Expand All @@ -315,7 +315,7 @@ impl<'a> std::fmt::Write for Formatter<'a> {
}
}

impl<'a> std::fmt::Debug for Formatter<'a> {
impl std::fmt::Debug for Formatter<'_> {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt.debug_struct("Formatter")
.field("line", &self.line)
Expand Down
13 changes: 8 additions & 5 deletions src/lang/nix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ impl Nix {
}
}
Import::With(with) => {
arguments.insert(with.argument.to_string());
let argument = with.argument.split('.').next();
if let Some(a) = argument {
arguments.insert(a.to_string());
}
}
}
}
Expand Down Expand Up @@ -356,8 +359,8 @@ where
/// ```
/// use genco::prelude::*;
///
/// let concat_map = nix::with("lib", "concatMap");
/// let list_to_attrs = nix::with("lib", "listToAttrs");
/// let concat_map = nix::with("inputs.nixpkgs.lib", "concatMap");
/// let list_to_attrs = nix::with("inputs.nixpkgs.lib", "listToAttrs");
///
/// let toks = quote! {
/// $list_to_attrs $concat_map
Expand All @@ -366,11 +369,11 @@ where
/// assert_eq!(
/// vec![
/// "{",
/// " lib,",
/// " inputs,",
/// " ...",
/// "}:",
/// "",
/// "with lib;",
/// "with inputs.nixpkgs.lib;",
/// "",
/// "listToAttrs concatMap",
/// ],
Expand Down
12 changes: 6 additions & 6 deletions src/tokens/format_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
/// assert_eq!("foo bar baz", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L> FormatInto<L> for &'a Tokens<L>
impl<L> FormatInto<L> for &Tokens<L>
where
L: Lang,
{
Expand Down Expand Up @@ -126,7 +126,7 @@ where
/// assert_eq!("foo bar baz", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L, T> FormatInto<L> for &'a [T]
impl<L, T> FormatInto<L> for &[T]
where
L: Lang,
T: Clone + FormatInto<L>,
Expand All @@ -153,7 +153,7 @@ where
/// assert_eq!("foo bar baz", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L> FormatInto<L> for &'a str
impl<L> FormatInto<L> for &str
where
L: Lang,
{
Expand All @@ -177,7 +177,7 @@ where
/// assert_eq!("foo bar baz", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L> FormatInto<L> for &'a String
impl<L> FormatInto<L> for &String
where
L: Lang,
{
Expand Down Expand Up @@ -253,7 +253,7 @@ where
/// assert_eq!("foo bar baz", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L> FormatInto<L> for &'a Rc<String>
impl<L> FormatInto<L> for &Rc<String>
where
L: Lang,
{
Expand All @@ -276,7 +276,7 @@ where
/// assert_eq!("Hello John", result.to_string()?);
/// # Ok::<_, genco::fmt::Error>(())
/// ```
impl<'a, L> FormatInto<L> for Arguments<'a>
impl<L> FormatInto<L> for Arguments<'_>
where
L: Lang,
{
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/item_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ where
}
}

impl<'a, L> FormatInto<L> for &'a ItemStr
impl<L> FormatInto<L> for &ItemStr
where
L: Lang,
{
Expand Down

0 comments on commit 12c24ea

Please sign in to comment.