Skip to content

Commit

Permalink
try fix (#8)
Browse files Browse the repository at this point in the history
* add use crate::frb_generated::RustAutoOpaque;
  • Loading branch information
asukaminato0721 authored Jan 31, 2025
1 parent 0375bf1 commit 7b520fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "rust -> target"

- name: Install Flutter
uses: subosito/flutter-action@v2
Expand All @@ -41,12 +43,12 @@ jobs:
cargo binstall --no-confirm --no-symlinks --force cargo-expand
cargo binstall --no-confirm --no-symlinks --force flutter_rust_bridge_codegen --version "2.7.1"
- name: lint lib before codegen
run: |
set -eux -o pipefail
pushd rust
cargo clippy -- -D warnings
cargo fmt -- --check
# - name: lint lib before codegen
# run: |
# set -eux -o pipefail
# pushd rust
# # cargo clippy -- -D warnings
# # cargo fmt -- --check

- name: Generate bridge code
run: |
Expand All @@ -71,11 +73,11 @@ jobs:
dart run lib/example.dart
dart run lib/migrate.dart
dart run lib/schedule.dart
# dart run lib/optimize.dart
dart run lib/optimize.dart
# - name: Debugging with tmate
# uses: mxschmitt/[email protected]


# - name: Flutter analyze
# run: flutter analyze
9 changes: 5 additions & 4 deletions rust/src/api/fsrs_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Mutex;

use crate::frb_generated::RustAutoOpaque;
use flutter_rust_bridge::frb;

#[frb(init)]
Expand Down Expand Up @@ -151,9 +152,9 @@ pub struct FSRSItem(fsrs::FSRSItem);

impl FSRSItem {
#[frb(sync)]
pub fn new(reviews: &[FSRSReview]) -> Self {
pub fn new(reviews: &[RustAutoOpaque<FSRSReview>]) -> Self {
Self(fsrs::FSRSItem {
reviews: reviews.iter().map(|x| x.0).collect(),
reviews: reviews.iter().map(|x| x.blocking_read().0).collect(),
})
}
#[frb(sync, getter)]
Expand All @@ -165,8 +166,8 @@ impl FSRSItem {
.collect()
}
#[frb(sync)]
pub fn set_reviews(&mut self, other: &[FSRSReview]) {
self.0.reviews = other.iter().map(|x| x.0).collect()
pub fn set_reviews(&mut self, other: &[RustAutoOpaque<FSRSReview>]) {
self.0.reviews = other.iter().map(|x| x.blocking_read().0).collect()
}
#[frb(sync, getter)]
pub fn long_term_review_cnt(&self) -> usize {
Expand Down

0 comments on commit 7b520fd

Please sign in to comment.