Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable Scalar Type Support #29

Open
dOrgJelli opened this issue Feb 4, 2022 · 1 comment
Open

Nullable Scalar Type Support #29

dOrgJelli opened this issue Feb 4, 2022 · 1 comment

Comments

@dOrgJelli
Copy link

Currently, the only "nullable" types that are supported are objects, since AssemblyScrpit does not natively support "nullable scalar types" (ex: value: boolean | null).

In order to support nullable scalar types, a utility class Nullable<T> can be used. An example implementation: https://github.com/polywrap/monorepo/blob/prealpha/packages/wasm/as/assembly/msgpack/Nullable.ts

Example usage:

const nullable = Nullable.fromValue<u32>(5);

nullable.isNull; // false
nullable.value; // 5
nullable.value = 0;
@Niraj-Kamdar
Copy link

Niraj-Kamdar commented Apr 13, 2022

Should we use Option primitive from the https://github.com/yjhmelody/as-container here?

This is Rust-inspired, has decent test coverage, and also allows references that we don't in the Nullable type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants