Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/car_example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ fn decode_car_and_assert_expected_content(buffer: &[u8]) -> CodecResult<()> {
println!("Activation Code: {}", activation_code);
assert_eq!("abcdef", activation_code);

let (position, buffer_back) = dec_done.unwrap();
let position = dec_done.unwrap();
println!("Finished decoding. Made it to position {0} out of {1}",
position,
buffer_back.len());
buffer.len());
Ok(())
}

Expand Down Expand Up @@ -202,7 +202,7 @@ fn encode_car_from_scratch() -> CodecResult<Vec<u8>> {
let enc_model = enc_manufacturer.manufacturer("Honda".as_bytes())?;
let enc_activation_code = enc_model.model("Civic VTi".as_bytes())?;
let done = enc_activation_code.activation_code("abcdef".as_bytes())?;
let (pos, _) = done.unwrap();
let pos = done.unwrap();
pos
};
println!("encoded up to position {}", used_pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ String generateDoneCoderType(
{
appendScratchWrappingStruct(writer, doneTypeName);
RustGenerator.appendImplWithLifetimeHeader(writer, doneTypeName);
writer.append(INDENT).append(String.format("pub fn unwrap(mut self) -> (usize, &%s%s [u8]) {\n",
DATA_LIFETIME, this == Encoder ? " mut" : ""))
.append(INDENT).append(INDENT).append(format("(self.%s.pos, self.%s.data)\n",
scratchProperty(), scratchProperty()))
.append(INDENT).append("}\n");
indent(writer, 1, "/// Returns the number of bytes %s\n", this == Encoder ? "encoded" : "decoded");
indent(writer, 1, "pub fn unwrap(self) -> usize {\n");
indent(writer, 2, "self.%s.pos\n", scratchProperty());
indent(writer, 1, "}\n");

appendWrapMethod(writer, doneTypeName);
writer.append("}\n");
Expand Down