Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: remove .borrow() calls in Askama templates for ItemTemplate implementors #112021

Closed
2 tasks
nicklimmm opened this issue May 27, 2023 · 2 comments · Fixed by #112202
Closed
2 tasks

rustdoc: remove .borrow() calls in Askama templates for ItemTemplate implementors #112021

nicklimmm opened this issue May 27, 2023 · 2 comments · Fixed by #112202
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@nicklimmm
Copy link
Contributor

Context:

Would like to hear more ideas to tackle this problem, but this is my proposal (rough idea):

  • Blanket impl of ItemTemplate for references: impl<T: ItemTemplate> ItemTemplate for &T
  • derive macro for ItemTemplate; One might ask, is there a need for macros here?
    • impl<T: ItemTemplate> askama::Template for &T is required
      • Can't apply blanket impl because it involves an external trait
      • So, we are left with implementing this trait for each &T, which can be done by copying the associated types and calling existing methods from T (basically making &T behave the same as T)

I suspect that we can gain more by creating macros here, but it is still under exploration.

cc @GuillaumeGomez

@GuillaumeGomez GuillaumeGomez added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 27, 2023
@nicklimmm
Copy link
Contributor Author

Pulling @notriddle in since the core idea was from him. Feel free to comment :)

I'll be creating the MVP while exploring what can we gain from using macros here.

@nicklimmm
Copy link
Contributor Author

Posted a draft PR for sharing the proof of concept (mentioned above), looking forward to suggestions :)

@bors bors closed this as completed in 7b6093e Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants