Prompt
Use Option
Key guidelines:
- Use Option
when a value may legitimately be absent - Avoid Option if a field is never None in practice
- Don’t use empty/default values as substitutes for Option
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>
}