-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate to Rust edition 2024 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| [package] | ||
| name = "cflib-rust" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| edition = "2024" | ||
|
|
||
| [lib] | ||
| name = "cflib_rust" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -93,22 +93,20 @@ impl Crazyflie { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toc_cache: Option<&Bound<'_, PyAny>>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> PyResult<Bound<'py, PyAny>> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Extract cache from Python object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cache = if let Some(cache_obj) = toc_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Try to extract each cache type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Ok(no_cache) = cache_obj.extract::<NoTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AnyCacheWrapper::NoCache(no_cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if let Ok(mem_cache) = cache_obj.extract::<InMemoryTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AnyCacheWrapper::InMemory(mem_cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if let Ok(file_cache) = cache_obj.extract::<FileTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AnyCacheWrapper::File(file_cache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return Err(PyRuntimeError::new_err( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "toc_cache must be NoTocCache, InMemoryTocCache, or FileTocCache" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Default to NoTocCache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AnyCacheWrapper::NoCache(NoTocCache) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cache = match toc_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Some(cache_obj) => match cache_obj.extract::<NoTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(no_cache) => AnyCacheWrapper::NoCache(no_cache), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ => match cache_obj.extract::<InMemoryTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(mem_cache) => AnyCacheWrapper::InMemory(mem_cache), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ => match cache_obj.extract::<FileTocCache>() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(file_cache) => AnyCacheWrapper::File(file_cache), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ => return Err(PyRuntimeError::new_err( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "toc_cache must be NoTocCache, InMemoryTocCache, or FileTocCache" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| None => AnyCacheWrapper::NoCache(NoTocCache), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+96
to
+109
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cache = match toc_cache { | |
| Some(cache_obj) => match cache_obj.extract::<NoTocCache>() { | |
| Ok(no_cache) => AnyCacheWrapper::NoCache(no_cache), | |
| _ => match cache_obj.extract::<InMemoryTocCache>() { | |
| Ok(mem_cache) => AnyCacheWrapper::InMemory(mem_cache), | |
| _ => match cache_obj.extract::<FileTocCache>() { | |
| Ok(file_cache) => AnyCacheWrapper::File(file_cache), | |
| _ => return Err(PyRuntimeError::new_err( | |
| "toc_cache must be NoTocCache, InMemoryTocCache, or FileTocCache" | |
| )), | |
| }, | |
| }, | |
| }, | |
| None => AnyCacheWrapper::NoCache(NoTocCache), | |
| let cache = if let Some(cache_obj) = toc_cache { | |
| if let Ok(no_cache) = cache_obj.extract::<NoTocCache>() { | |
| AnyCacheWrapper::NoCache(no_cache) | |
| } else if let Ok(mem_cache) = cache_obj.extract::<InMemoryTocCache>() { | |
| AnyCacheWrapper::InMemory(mem_cache) | |
| } else if let Ok(file_cache) = cache_obj.extract::<FileTocCache>() { | |
| AnyCacheWrapper::File(file_cache) | |
| } else { | |
| return Err(PyRuntimeError::new_err( | |
| "toc_cache must be NoTocCache, InMemoryTocCache, or FileTocCache" | |
| )); | |
| } | |
| } else { | |
| AnyCacheWrapper::NoCache(NoTocCache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo fix --edition did this for me,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching the crate to edition 2024 effectively raises the minimum supported Rust toolchain (older compilers will fail to parse/build). To make this explicit and avoid confusing build failures in downstream environments, add an explicit MSRV (e.g.,
rust-version) and/or a repo-level toolchain pin (rust-toolchain.toml) that matches the intended minimum.