Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Null

Type name: null

Rust type: ()

This is the most basic data type, representing the absence of a value.

<null />

Conversion to other types

When converting null to other types, it converts to the following values:

<unwrap>

The <unwrap> element is used to throw an error if its child is null. If the child is not null, it returns the child value.

It optionally receives the message attribute, which is used as the error message if the child is null.

<unwrap><null /></unwrap> <!-- Error: "Unwrapped value is null" -->
<unwrap message="Custom error message"><null /></unwrap> <!-- Error: "Custom error message" -->
<unwrap><int>42</int></unwrap> <!-- 42 -->