mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 14:58:12 +08:00
Upgrade to the Rust 2024 edition (#2367)
* Update to rust 2024 edition * Fixes * Clean up imports * Cargo fmt again --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
927d7dd9b2
commit
beb1c6ae64
@@ -39,14 +39,9 @@ Please make a habit of grouping together related lines of code in blocks separat
|
||||
|
||||
## Imports
|
||||
|
||||
Our imports used to be a mess before we tamed the chaos with these rules.
|
||||
Our imports used to be a mess before we tamed the chaos with a formatting rule that has to be applied manually, since `rustfmt` doesn't support it.
|
||||
|
||||
At the top of Rust files, use the convention of separating imports into three blocks, ordered as:
|
||||
1. Local (`use super::` and `use crate::`)
|
||||
2. First-party crates (e.g. `use editor::` or `bezier_rs::`)
|
||||
3. Third-party libraries (e.g. `use std::` or `use glam::`)
|
||||
|
||||
Combine related imports with common paths at the same depth. For example:
|
||||
We always combine imports with common paths, but only at the same depth. For example:
|
||||
|
||||
```rs
|
||||
use crate::A::B::C;
|
||||
@@ -58,4 +53,13 @@ use crate::A::B::C::Bar;
|
||||
use crate::A::B::C::{self, Foo, Bar};
|
||||
```
|
||||
|
||||
But do not combine imports at mixed path depths. For example, `use crate::A::{B::C::Foo, X::Hello};` should be split into two separate import lines— avoid having `::` inside `{}`.
|
||||
But we do not combine imports at mixed path depths. In other words, never put `::` inside `{}`. For example:
|
||||
|
||||
```rs
|
||||
use crate::A::{B::C::Foo, X::Hello};
|
||||
|
||||
// Should be separated into:
|
||||
|
||||
use crate::A::B::C::Foo;
|
||||
use crate::A::X::Hello;
|
||||
```
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
name = "bezier-rs-wasm"
|
||||
publish = false
|
||||
version = "0.0.0"
|
||||
rust-version = "1.79"
|
||||
rust-version = "1.85"
|
||||
authors = ["Graphite Authors <contact@graphite.rs>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
readme = "../../README.md"
|
||||
homepage = "https://graphite.rs"
|
||||
repository = "https://github.com/GraphiteEditor/Graphite"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use crate::svg_drawing::*;
|
||||
use crate::utils::{parse_cap, parse_point};
|
||||
|
||||
use bezier_rs::{ArcStrategy, ArcsOptions, Bezier, Identifier, TValue, TValueType};
|
||||
|
||||
use glam::DVec2;
|
||||
use js_sys::Array;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use crate::svg_drawing::*;
|
||||
use crate::utils::{parse_cap, parse_join, parse_point};
|
||||
|
||||
use bezier_rs::{Bezier, ManipulatorGroup, Subpath, SubpathTValue, TValueType};
|
||||
|
||||
use glam::DVec2;
|
||||
use js_sys::Array;
|
||||
use js_sys::Math;
|
||||
|
||||
Reference in New Issue
Block a user