We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9fc08b8 commit da0c13cCopy full SHA for da0c13c
guide/src/reference/static-js-objects.md
@@ -70,9 +70,10 @@ extern "C" {
70
}
71
```
72
73
-## Undeclared
+## Optional statics
74
75
-When accessing an in JS undeclared value, it will throw in JS. This can be accounted for by using `Option`.
+If you expect the JavaScript value you're trying to access to not always be
76
+available you can use `Option<T>` to handle this:
77
78
```rust
79
extern "C" {
@@ -82,7 +83,9 @@ extern "C" {
82
83
84
85
-If `crypto` is undeclared in JS, it will simply return `None` in Rust.
86
+If `crypto` is not declared or nullish (`null` or `undefined`) in JavaScript,
87
+it will simply return `None` in Rust. This will also account for namespaces: it
88
+will return `Some(T)` only if all parts are declared and not nullish.
89
90
## Static strings
91
0 commit comments