Skip to content

Use try blocks for error handling in lib.rs#61

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/use-try-block-in-lib
Draft

Use try blocks for error handling in lib.rs#61
Copilot wants to merge 3 commits intomainfrom
copilot/use-try-block-in-lib

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

Refactor error handling to use Rust's nightly try_blocks feature as requested.

Changes

  • Add #![feature(try_blocks)] crate attribute
  • Add rust-toolchain.toml to specify nightly channel
  • Refactor next_states, memory_state_from_sm2, and memory_state methods to use try block pattern

Example

Before:

self.0.lock().unwrap().next_states(...).unwrap()

After:

(try {
    self.0.lock().unwrap().next_states(...)?
} as Result<_, fsrs::FSRSError>).unwrap()
Original prompt

This section details on the original issue you should resolve

<issue_title>try try</issue_title>
<issue_description>

NextStates(
self.0
.lock()
.unwrap()
.next_states(
current_memory_state.map(|x| x.0),
desired_retention,
days_elapsed,
)
.unwrap(),
)

use try block to rewrite them as

try {
   x?
   y?
}.unwrap()

Can use nightly.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Refactor error handling with try blocks in lib.rs Use try blocks for error handling in lib.rs Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

try try

2 participants