File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,10 @@ extern "C" {
70
70
}
71
71
```
72
72
73
- ## Undeclared
73
+ ## Optional statics
74
74
75
- When accessing an in JS undeclared value, it will throw in JS. This can be accounted for by using ` Option ` .
75
+ 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:
76
77
77
78
``` rust
78
79
extern " C" {
@@ -82,7 +83,9 @@ extern "C" {
82
83
}
83
84
```
84
85
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.
86
89
87
90
## Static strings
88
91
You can’t perform that action at this time.
0 commit comments