Skip to content

Commit

Permalink
feat!: Make the core crate no-std (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcampbell authored Oct 22, 2024
1 parent c1bd2d6 commit 2fa0d3f
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ features = ["schemars", "serde"]
enumn = { version = "0.1.6", optional = true }
pyo3 = { version = "0.20", optional = true }
schemars = { version = "0.8.7", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }

[features]
enumn = ["dep:enumn"]
Expand Down
16 changes: 1 addition & 15 deletions common/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// the LICENSE-APACHE file) or the MIT license (found in
// the LICENSE-MIT file), at your option.

use std::{
use core::{
fmt,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},
};
Expand Down Expand Up @@ -67,20 +67,6 @@ impl Affine {
Affine([s_x, 0.0, 0.0, s_y, 0.0, 0.0])
}

/// An affine transform representing rotation.
///
/// The convention for rotation is that a positive angle rotates a
/// positive X direction into positive Y. Thus, in a Y-down coordinate
/// system (as is common for graphics), it is a clockwise rotation, and
/// in Y-up (traditional for math), it is anti-clockwise.
///
/// The angle, `th`, is expressed in radians.
#[inline]
pub fn rotate(th: f64) -> Affine {
let (s, c) = th.sin_cos();
Affine([c, s, -s, c, 0.0, 0.0])
}

/// An affine transform representing translation.
#[inline]
pub fn translate<V: Into<Vec2>>(p: V) -> Affine {
Expand Down
7 changes: 6 additions & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.chromium file.

#![cfg_attr(not(any(feature = "pyo3", feature = "schemars")), no_std)]

extern crate alloc;

use alloc::{boxed::Box, string::String, vec::Vec};
use core::fmt;
#[cfg(feature = "pyo3")]
use pyo3::pyclass;
#[cfg(feature = "schemars")]
Expand All @@ -22,7 +28,6 @@ use serde::{
ser::{SerializeMap, Serializer},
Deserialize, Serialize,
};
use std::fmt;

mod geometry;
pub use geometry::{Affine, Point, Rect, Size, Vec2};
Expand Down
1 change: 0 additions & 1 deletion consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ rust-version.workspace = true
[dependencies]
accesskit = { version = "0.16.3", path = "../common" }
immutable-chunkmap = "2.0.5"

1 change: 1 addition & 0 deletions platforms/atspi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ atspi-common = { version = "0.6", default-features = false }
serde = "1.0"
thiserror = "1.0"
zvariant = { version = "4.2", default-features = false }

1 change: 1 addition & 0 deletions platforms/macos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ objc2-app-kit = { version = "0.2.0", features = [
"NSView",
"NSWindow",
] }

1 change: 0 additions & 1 deletion platforms/unix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ tokio-stream = { version = "0.1.14", optional = true }
version = "1.32.0"
optional = true
features = ["macros", "net", "rt", "sync", "time"]

1 change: 0 additions & 1 deletion platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ features = [
once_cell = "1.13.0"
scopeguard = "1.1.0"
winit = "0.30"

1 change: 0 additions & 1 deletion platforms/winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ accesskit_unix = { version = "0.12.3", path = "../unix", optional = true, defaul
version = "0.30"
default-features = false
features = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]

0 comments on commit 2fa0d3f

Please sign in to comment.