You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a slab::Slab to store nodes for my DOM implementation. The new immutable API in html5ever 0.28 has required me to wrap my node tree in a RefCell so that I can mutate it from html5ever's trait methods. However, html5ever's ExpandedName<'a> type also requires me to return a (plain) reference into my tree, which is not possible if my tree is wrapped in a RefCell.
I believe the best fix for this (assuming that the new interior mutability-based API is indeed necessary - it seems awkward!) is to make ExpandedName an associated type on the TreeSink trait which implements AsRef<ExpandedName> or alternatively has methods to access the fields of ExpandedName individually. This would allow implementers of TreeSink to choose one of the following strategies:
Use the existing ExpandedName type if their tree supports it.
Use a variant of ExpandedName that uses a RefCell Ref (or MutexGuard, etc)
Return cloned/owned names
I would be happy to put up a PR for this if this seems like a reasonable solution. I have not yet completed my migration, so I am unsure if I will run into further problems. I have now migrated the rest of the code. This seems to be the only thing I couldn't solve with a RefCell.
The text was updated successfully, but these errors were encountered:
I am using a
slab::Slab
to store nodes for my DOM implementation. The new immutable API in html5ever 0.28 has required me to wrap my node tree in aRefCell
so that I can mutate it from html5ever's trait methods. However, html5ever'sExpandedName<'a>
type also requires me to return a (plain) reference into my tree, which is not possible if my tree is wrapped in aRefCell
.I believe the best fix for this (assuming that the new interior mutability-based API is indeed necessary - it seems awkward!) is to make
ExpandedName
an associated type on theTreeSink
trait which implementsAsRef<ExpandedName>
or alternatively has methods to access the fields of ExpandedName individually. This would allow implementers ofTreeSink
to choose one of the following strategies:Ref
(orMutexGuard
, etc)I would be happy to put up a PR for this if this seems like a reasonable solution.
I have not yet completed my migration, so I am unsure if I will run into further problems.I have now migrated the rest of the code. This seems to be the only thing I couldn't solve with aRefCell
.The text was updated successfully, but these errors were encountered: