ok/jj
1
0
Fork 0
forked from mirrors/jj
jj/cli
Yuya Nishihara cecae849aa templater: don't define TemplateLanguage::Context statically
In short, this enables compilation of template of e.g. Vec<Commit> type by
using CommitTemplateLanguage.

A Template<C> was originally compiled for a specific type C, and invoked as
"Fn(&C) -> _". It was simple and intuitive, but we had to define the context
type C statically. Things got even worse by extensions support because we had
to provide object-safe hook point for each context type C.

This patch basically removes the Context type from compiled templates. The
"self" variable is injected through RefCell<Option<C>> placeholder. A compiled
template knows its "self" type, but the type can be decided per instance, not
per TemplateLanguage type. A drawback is that the "self" variable will have to
be cloned one more time.

The Template<C> abstraction no longer makes sense, and will be split to inner
Template<()> implementations (which usually represent printable types) and the
outer Template<C>.
2024-03-22 11:51:15 +09:00
..
examples templater: allow use of wrap_<type>() functions without borrowing &language 2024-03-22 11:51:15 +09:00
src templater: don't define TemplateLanguage::Context statically 2024-03-22 11:51:15 +09:00
testing revset: substitute '~(::x)' to 'x..' 2024-03-17 14:50:48 +09:00
tests Make node symbols templatable in the graphs. 2024-03-21 17:41:31 +01:00
build.rs
Cargo.toml templater: add similarity hint to no such method/keyword errors 2024-02-28 09:03:04 +09:00
LICENSE