Use Option
Use Option
Key guidelines:
Example:
// Good: Truly optional value
struct Config {
refresh_interval: Option<Duration>, // May not be configured
error_message: Option<String> // Only present on error
}
// Bad: Using Option when value is never None
struct AuthInterceptor {
tenant_id: AsciiMetadataValue,
shard_id: Option<AsciiMetadataValue> // If always present, remove Option
}
// Bad: Using empty string instead of Option
struct Settings {
base_url: String // Empty string is meaningless, use Option<String>
}
Enter the URL of a public GitHub repository