-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Postprocessor type does not enable storing state in the postprocessor #175
Comments
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 22, 2023
This lets the compiler reason about the lifetimes of objects used by the postprocessor, if the callback captures variables. See zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 22, 2023
These are like the Postprocessor callback function type, but they can be implemented on types for more ergonomic stateful postprocessing. Fixes zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 22, 2023
This lets the compiler reason about the lifetimes of objects used by the postprocessor, if the callback captures variables. See zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 22, 2023
This lets the compiler reason about the lifetimes of objects used by the postprocessor, if the callback captures variables. See zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 22, 2023
These are like the Postprocessor callback function type, but they can be implemented on types for more ergonomic stateful postprocessing. Fixes zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 24, 2023
This lets the compiler reason about the lifetimes of objects used by the postprocessor, if the callback captures variables. See zoni#175
zoni
pushed a commit
that referenced
this issue
Sep 25, 2023
This lets the compiler reason about the lifetimes of objects used by the postprocessor, if the callback captures variables. See #175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Sep 25, 2023
These are like the Postprocessor callback function type, but they can be implemented on types for more ergonomic stateful postprocessing. Fixes zoni#175
rsesek
added a commit
to rsesek/obsidian-export
that referenced
this issue
Oct 8, 2023
These are like the Postprocessor callback function type, but they can be implemented on types for more ergonomic stateful postprocessing. Fixes zoni#175
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The type definition for
Postprocessor
is:When using obsidian-export as a library, this makes it impossible to create a postprocessor that accumulates state as notes are processed. For example, let's say you wanted to collect all the directory parents containing markdown files to produce an index page. The following code:
… results in:
This can be fixed by adding a lifetime annotation to
Postprocessor
so that'static
is not assumed by the compiler.But the callback can be somewhat clunky, if the client code is storing state on a struct (as opposed to the example above just capturing a local). E.g., given something like this:
The caller needs to move the closure binding to a local given this error:
It seems like it would be more ergonomic still to provide a trait for postprocessing. I propose addressing both of these: add a lifetime to the
Postprocessor
type, and define traits for postprocessing.The text was updated successfully, but these errors were encountered: