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

Allow output of Renderer to reference bits of the application state #1

Open
cramertj opened this issue Jan 9, 2017 · 0 comments
Open

Comments

@cramertj
Copy link
Owner

cramertj commented Jan 9, 2017

This would save a bunch of unnecessary allocations, and it is entirely safe since the state can't be modified between Renderer::render being called and the DomNode being drawn to the page. However, I don't think this is possible without ATCs, as the lifetime of the returned DomNode would be dependent upon the lifetime of the reference to the application state.

The modified Renderer trait might look something like this:

pub trait Renderer<State> {
    /// Type of the rendered `DomNode`
    type Rendered<'a>: DomNode + 'a;

    /// Renders a `DomNode` given the current application state
    fn render<'a>(&'a self, &'a State) -> Self::Rendered<'a>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant