google / google/pdl

Generate From<> rust conversions when the encoding is infallible

Open
#161 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
86
Forks
18
Avg merge
20h 49m
Merged PRs (30d)
1

Description

When converting from a child packet to a parent the encoding is often infallible, but the rust backend still generates TryFrom<> implementations instead of From<>.

For example:

```
packet Command {
op_code: 8,
_size_(_payload_),
_payload_,
}

packet OneCommand : Command (op_code = 1) {
x: 16,
y: 16,
}
```

Generates

```
impl TryFrom for Command {}
```

When the conversion can never fail.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.