Provide stricter types and restructure concerning types. #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additionally:
V8
prefixes for many structs and functions. It is unnecessary since all such types are already scoped within thev8-rs
crate and even within thev8
module, which already means (twice) that the type is aV8
type.Value
, which is an enumeration of some other possible values of JavaScript. This allows to have a clear distinction between the types and allows for a much easier, compile-time checked pattern matching.std::convert::TryFrom
andstd::convert::From
are used. This allows always to have a meaningful error message, avoids if/else conditions in favour of the conversion with an early return, and all the other cases are covered with the pattern matching of the value type.Type
enum for theLocalValueAny
type, which is generic and may contain any value. Adding this method instead ofis_X
allows using a much more advancedmatch
statement, which is also much more strict when it comes to covering all the possible types (by having no fall-through).