-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Milestone
Description
Fix async usage of FileStateMachine::new.
FileStateMachine::new is synchronous (Result<Self>), but the snippet calls .await?. This won’t compile—await on a non-Future and ? on a value already moved into Arc::new. Drop the .await so the example reflects the actual API.
- let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine")).await?);
+ let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine"))?);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Configure storage
let path = PathBuf::from("/tmp/db");
let storage_engine = Arc::new(FileStorageEngine::new(path.join("storage"))?);
let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine"))?);
🤖 Prompt for AI Agents
In README.md around lines 54 to 58, the example incorrectly uses `.await?` for
FileStateMachine::new (which returns Result<Self>, not a Future) and applies `?`
inside Arc::new; remove the `.await` and ensure the fallible call is resolved
before/while constructing the Arc (e.g., call
FileStateMachine::new(path.join("state_machine"))? and pass the resulting value
into Arc::new) so the code compiles and error propagation works as intended.
Originally posted by @coderabbitai[bot] in #149 (comment)
Reactions are currently unavailable