Skip to content

QuadSource <--> TripleSource conversion #110

Answered by pchampin
damooo asked this question in Q&A
Discussion options

You must be logged in to vote

The original idea was that the following code would do the trick:

my_quad_source.map_quads(Quad::wrap_as_triple)

Indeed quad::stream::MapSource implements TripleSource if the passed closure produces Triples (see API doc).
Unfortunately, this does not work in the general case, because of some arcane lifetime issue :-/ My bad.

A workaround consist in writing your own function that copies the terms of the quad, e.g.:

fn q2t<Q: Quad>(q: Q) -> [BoxTerm; 3] {
    [q.s().copied(), q.p().copied(), q.o().copied()]
}

and then

let triple_src = quad_src.map_quads(|q| q2t(q));

Ultimately, I hope to get the example above working (the one using Quad:wrap_as_triple), but that may occur only in release 0.…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@damooo
Comment options

Answer selected by damooo
Comment options

You must be logged in to vote
1 reply
@pchampin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants