Ensure that the pointer is not null. Raises: NullPointerError: Address of pointer is `None` Returns: Address of the pointer. Example: ```py ptr = to_ptr(NULL) address = ptr.ensure() # NullPointerError
(self)
| 58 | |
| 59 | @final |
| 60 | def ensure(self) -> int: |
| 61 | """Ensure that the pointer is not null. |
| 62 | |
| 63 | Raises: |
| 64 | NullPointerError: Address of pointer is `None` |
| 65 | |
| 66 | Returns: |
| 67 | Address of the pointer. |
| 68 | |
| 69 | Example: |
| 70 | ```py |
| 71 | ptr = to_ptr(NULL) |
| 72 | address = ptr.ensure() # NullPointerError |
| 73 | ptr >>= 1 |
| 74 | address = ptr.ensure() # works just fine |
| 75 | ```""" |
| 76 | |
| 77 | if not self.address: |
| 78 | raise NullPointerError("pointer is NULL") |
| 79 | return self.address |
| 80 | |
| 81 | |
| 82 | class Movable(ABC, Generic[T, A]): |
no test coverage detected