From b72b0433164e4a4d6afbe807c2d9cd60811338c1 Mon Sep 17 00:00:00 2001 From: Khushboo Desai Date: Tue, 5 Nov 2024 10:31:01 -0800 Subject: [PATCH] Adds changes for rust code blocks --- src/bin/ion/commands/generate/README.md | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/bin/ion/commands/generate/README.md b/src/bin/ion/commands/generate/README.md index 1ee94fc1..25a0a887 100644 --- a/src/bin/ion/commands/generate/README.md +++ b/src/bin/ion/commands/generate/README.md @@ -343,10 +343,10 @@ types defined within the outer types. Generated type has a `readFrom` method which can be used to read Ion data using `Reader` and initialize the generated type with the given Ion data. *(Generated code here depends on `ion-rs` version `1.0.0-rc.2`)* -```rust -let mut reader: Reader = ReaderBuilder::new().build(ION_DATA) ?; -reader.next() ?; -let foo: Foo = Foo::read_from( & mut reader) ?; +``` +let mut reader: Reader = ReaderBuilder::new().build(ION_DATA)?; +reader.next()?; +let foo: Foo = Foo::read_from(&mut reader)?; ``` ### Write a generated type to an `Writer` @@ -354,10 +354,10 @@ let foo: Foo = Foo::read_from( & mut reader) ?; Generated type has a `writeTo` method which can be used to write the type as Ion using `Writer` . *(Generated code here depends on `ion-rs` version `1.0.0-rc.2`)* -```rust -let mut text_writer = TextWriterBuilder::default ().build( & mut buffer) ?; -foo.write_to( & mut text_writer) ?; -text_writer.flush() ?; +``` +let mut text_writer = TextWriterBuilder::default().build(&mut buffer)?; +foo.write_to(&mut text_writer)?; +text_writer.flush()?; ``` ## Appendix A – Built-in ISL types and corresponding generated types @@ -403,18 +403,20 @@ the model as Ion data) are defined.* **Ion Schema:** ``` + type::{ - // this will be used as the name of the generated class - name: person, - // currently code generation doesn't allow open ended types, - // so for defining a `type` constraint is required - type: struct, - fields:{ - first_name: string, - last_name: string, - age: int, - } +// this will be used as the name of the generated class +name: person, +// currently code generation doesn't allow open ended types, +// so for defining a `type` constraint is required +type: struct, +fields:{ +first_name: string, +last_name: string, +age: int, +} } + ``` **Generated Code in Java:**