Closed tcbrindle closed 1 year ago
Patch coverage: 100.00
% and project coverage change: +0.01
:tada:
Comparison is base (
8459b7e
) 97.83% compared to head (1a341cb
) 97.85%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Given a sequence
seq
,cursors(seq)
returns a new sequence whose elements are, unsurprisingly, the cursors of the original sequence. The cursors sequence retains all the capabilities of the source sequence (bidir, RA, sized etc), not including contiguous_sequence.This is basically a passthrough adaptor, except that
read_at(seq, cur)
just returns a copy ofcur
. (The copy is required becauseread_at
accepts a const reference for its second argument, which can be initialised with a temporary, which can otherwise cause lifetime issues.)Unlike every other adaptor function,cursors()
takes an lvalue reference as its argument (all the others behave as if they take their arguments by value). The reason is that generally you can't do anything with a cursor unless you have its original sequence still available, so almost every real-world use ofcursors()
will actually want to doflux::ref(seq).cursors()
which is a lot more typing, socursors()
basically does the ref bit for you.However, this goes against the Flux principle that long-lived references should be explicitly formed by the user, and is inconsistent with all the other adaptor functions so I'm not sure it's really a good idea.EDIT: I changed my mind,
cursors()
now requiresadaptable_sequence
like all the other adaptors.