Closed pchampin closed 4 months ago
This should probably be achieved by adding a second generic parameter to
GenericTerm
, for the content of theTriple
variant.
In fact, using Self in generic types seems to be forbidden. An alternative option is to turn GenericTerm into a macro generating the implementation of ArcTerm and RcTerm...
As a side-note, more than ArcTerm
, it would be great to have an EcoTerm
using EcoString
. EcoString
has phenomenal properties. It is cheap to clone. And can also be mutable (clone-on-write), and can have small strings (upto 15 bytes) inlined without allocation.
It also has correspondent EcoVec
, with same properties. The crate is from typst
team, and also recommonded by rust-analyzer author. Works great in Manas too.
@damoo EcoTerm would indeed be nice. I would rather keep ArcTerm and RcTerm as they don't require additional dependencies, but adding EcoTerm in sophia_term, behind a feature gate, would be a very nice addition...
adding EcoTerm in sophia_term, behind a feature gate, would be a very nice addition...
That would still be a separate issue, though.
One reason for using
RcTerm
orArcTerm
is that they are cheaper to clone thanSimpleTerm
s (SimpleTerm
usesMownStr
internally, which may require a new allocation on cloning -- when they own their data).However, in their current implementation, the
Triple
variant ofRcTerm
andArcTerm
are still expensive to clone, as they contain aBox
(which also needs a new allocation when cloned). Instead,RcTerm::Triple
should contain aRc<[RcTerm; 3]>
andArcTerm::Triple
should contain aArc<[ArcTerm; 3]>
.This should probably be achieved by adding a second generic parameter to
GenericTerm
, for the content of theTriple
variant.