I\'m trying to get a value for a query, but this value can be NULL and I don\'t know how to handle it in Rust. Here is my code:
let stmt = conn.prepare(\"SEL
As described in the documentation:
Nullability
In addition to the types listed above,
FromSql
is implemented forOption<T>
whereT
implementsFromSql
. AnOption<T>
represents a nullable Postgres value.
Request an Option<Type>
for the field that can be NULL; then the library will automatically convert NULL to None
:
let rating: Option<String> = row.get("rating");