generalize the `Option<NonNullablePtr>` to libs

Closes #7576