Skip to content

Make SequenceWriter generic over Error type#599

Closed
facutuesca wants to merge 1 commit intoalex:claude/add-writable-error-type-dAyLZfrom
trail-of-forks:ft/sequencewriter-generic-error
Closed

Make SequenceWriter generic over Error type#599
facutuesca wants to merge 1 commit intoalex:claude/add-writable-error-type-dAyLZfrom
trail-of-forks:ft/sequencewriter-generic-error

Conversation

@facutuesca
Copy link
Contributor

@alex
Copy link
Owner

alex commented Feb 24, 2026

Hmm, is it not able to infer the type even when its the default?

Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
@facutuesca facutuesca force-pushed the ft/sequencewriter-generic-error branch from 16682eb to 30078a9 Compare February 24, 2026 18:41
@facutuesca
Copy link
Contributor Author

Hmm, is it not able to infer the type even when its the default?

doesn't seem so:

error[E0283]: type annotations needed
   --> examples/no_std.rs:20:26
    |
20  |         w.write_element(&asn1::SequenceWriter::new(&|w: &mut asn1::Writer| {
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `E` declared on the struct `SequenceWriter`
    |
    = note: cannot satisfy `_: From<WriteError>`
note: required by a bound in `asn1::write`
   --> /Users/facu/repos/rust-asn1/src/writer.rs:210:17
    |
210 | pub fn write<E: From<WriteError>, F: Fn(&mut Writer<'_>) -> Result<(), E>>(
    |                 ^^^^^^^^^^^^^^^^ required by this bound in `write`
help: consider specifying the generic argument
    |
20  -         w.write_element(&asn1::SequenceWriter::new(&|w: &mut asn1::Writer| {
20  +         w.write_element(&asn1::SequenceWriter::<E>(&|w: &mut asn1::Writer| {
    |

@alex
Copy link
Owner

alex commented Feb 24, 2026

🙃 what's the point of the default if it doesn't work in this situation?

@facutuesca
Copy link
Contributor Author

facutuesca commented Feb 24, 2026

🙃 what's the point of the default if it doesn't work in this situation?

yeah. Looks related to this: rust-lang/rust#98931

edit: also rust-lang/rust#27336

@reaperhulk reaperhulk deleted the branch alex:claude/add-writable-error-type-dAyLZ February 25, 2026 22:31
@reaperhulk reaperhulk closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants