Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

impl<T> Ranged for &T where T: Ranged #16

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Jun 26, 2023

In the example below, arg is &Expr, so &Ranged, but entries() want a T: Ranged. This adds the missing bridge impl.

        let all_args = format_with(|f| {
            f.join_comma_separated()
                .entries(
                    // We have the parentheses from the call so the arguments never need any
                    args.iter()
                        .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                )
                .nodes(keywords.iter())
                .finish()
        });

@konstin konstin requested a review from MichaReiser June 26, 2023 09:34
konstin added 2 commits June 26, 2023 12:18
This needs explicit dispatch or the recursive version takes precedence
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@konstin konstin merged commit c174bbf into main Jun 26, 2023
@konstin konstin deleted the impl_T_Ranged_for_T_where_T_Ranged branch June 26, 2023 11:55
zanieb pushed a commit that referenced this pull request Jul 10, 2023
In the example below, `arg` is `&Expr`, so `&Ranged`, but `entries()`
want a `T: Ranged`. This adds the missing bridge impl.

```rust
        let all_args = format_with(|f| {
            f.join_comma_separated()
                .entries(
                    // We have the parentheses from the call so the arguments never need any
                    args.iter()
                        .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                )
                .nodes(keywords.iter())
                .finish()
        });
```
zanieb pushed a commit that referenced this pull request Jul 17, 2023
In the example below, `arg` is `&Expr`, so `&Ranged`, but `entries()`
want a `T: Ranged`. This adds the missing bridge impl.

```rust
        let all_args = format_with(|f| {
            f.join_comma_separated()
                .entries(
                    // We have the parentheses from the call so the arguments never need any
                    args.iter()
                        .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                )
                .nodes(keywords.iter())
                .finish()
        });
```
zanieb pushed a commit that referenced this pull request Jul 17, 2023
In the example below, `arg` is `&Expr`, so `&Ranged`, but `entries()`
want a `T: Ranged`. This adds the missing bridge impl.

```rust
        let all_args = format_with(|f| {
            f.join_comma_separated()
                .entries(
                    // We have the parentheses from the call so the arguments never need any
                    args.iter()
                        .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                )
                .nodes(keywords.iter())
                .finish()
        });
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants