You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user-guide/type-mapping/characters.qmd
+52
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,34 @@ let bytes = bytes.as_bytes().to_owned();
34
34
bytes
35
35
```
36
36
37
+
38
+
Let us investigate the address of these two identical snippets of data
39
+
40
+
```{extendrsrc}
41
+
#[extendr]
42
+
fn hello_world() -> &'static str {
43
+
let hello_world = "Hello World!";
44
+
rprintln!("Address of the Rust `hello_world`: {:p}", hello_world.as_ptr());
45
+
hello_world
46
+
}
47
+
```
48
+
49
+
50
+
```{r}
51
+
hello_world()
52
+
```
53
+
54
+
And the adress of `hello_world`, once it is part of the R runtime:
55
+
56
+
```{r}
57
+
.Internal(inspect(hello_world()))
58
+
```
59
+
60
+
::::: {.callout-note}
61
+
The return type of `hello_world` need not be `'static str`. The life-time can be made
62
+
arbitrary, such as `fn hello_world<'a>() -> &'a str`.
63
+
:::
64
+
37
65
A `character`-vector in R could be compared to a `Vec<String>` in Rust. However, there is an important distinction, that we'll illustrate with an example.
0 commit comments