File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -141,10 +141,36 @@ error[E0277]: the trait bound `Shape: ToVectorValue` is not satisfied
141141 |
142142```
143143
144- However, if an impl block is added to the ` Shape ` enum, it can be returned to R.
144+ However, you add the ` #[extendr] ` attribute to the ` Shape ` enum, it can be returned to R.
145145
146146``` {extendrsrc}
147147#[derive(Debug)]
148+ #[extendr]
149+ enum Shape {
150+ Triangle,
151+ Rectangle,
152+ Pentagon,
153+ Hexagon,
154+ }
155+
156+ #[extendr]
157+ fn make_shape(shape: &str) -> Shape {
158+ match shape {
159+ "triangle" => Shape::Triangle,
160+ "rectangle" => Shape::Rectangle,
161+ "pentagon" => Shape::Pentagon,
162+ "hexagon" => Shape::Hexagon,
163+ &_ => unimplemented!()
164+ }
165+ }
166+
167+ ```
168+
169+ It is also possible to add methods to structs/enums and their instances:
170+
171+ ``` {extendrsrc}
172+ #[derive(Debug)]
173+ #[extendr]
148174enum Shape {
149175 Triangle,
150176 Rectangle,
You can’t perform that action at this time.
0 commit comments