Skip to content

Commit cc744a2

Browse files
committed
Make objc2 optional in core-graphics-types
1 parent 7383217 commit cc744a2

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

cocoa-foundation/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ block2 = "0.2.0"
1616
bitflags = "1.0"
1717
libc = "0.2"
1818
core-foundation = { path = "../core-foundation", version = "0.9" }
19-
core-graphics-types = { path = "../core-graphics-types", version = "0.1" }
19+
core-graphics-types = { path = "../core-graphics-types", version = "0.1", features = ["objc2"] }
2020
objc2 = "0.4.0"

core-graphics-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
1111
bitflags = "1.0"
1212
core-foundation = { path = "../core-foundation", version = "0.9" }
1313
libc = "0.2"
14-
objc2 = "0.4.0"
14+
objc2 = { version = "0.4.0", optional = true }
1515

1616
[package.metadata.docs.rs]
1717
default-target = "x86_64-apple-darwin"

core-graphics-types/src/geometry.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use base::CGFloat;
1111
use core_foundation::base::TCFType;
1212
use core_foundation::dictionary::CFDictionary;
13+
#[cfg(feature = "objc2")]
1314
use objc2::encode::{Encode, Encoding};
1415

1516
pub const CG_ZERO_POINT: CGPoint = CGPoint { x: 0.0, y: 0.0 };
@@ -40,6 +41,7 @@ pub struct CGSize {
4041
pub height: CGFloat,
4142
}
4243

44+
#[cfg(feature = "objc2")]
4345
unsafe impl Encode for CGSize {
4446
const ENCODING: Encoding = Encoding::Struct("CGSize", &[CGFloat::ENCODING, CGFloat::ENCODING]);
4547
}
@@ -66,6 +68,7 @@ pub struct CGPoint {
6668
pub y: CGFloat,
6769
}
6870

71+
#[cfg(feature = "objc2")]
6972
unsafe impl Encode for CGPoint {
7073
const ENCODING: Encoding = Encoding::Struct("CGPoint", &[CGFloat::ENCODING, CGFloat::ENCODING]);
7174
}
@@ -89,6 +92,7 @@ pub struct CGRect {
8992
pub size: CGSize,
9093
}
9194

95+
#[cfg(feature = "objc2")]
9296
unsafe impl Encode for CGRect {
9397
const ENCODING: Encoding = Encoding::Struct("CGRect", &[CGPoint::ENCODING, CGSize::ENCODING]);
9498
}
@@ -158,6 +162,7 @@ pub struct CGAffineTransform {
158162
pub ty: CGFloat,
159163
}
160164

165+
#[cfg(feature = "objc2")]
161166
unsafe impl Encode for CGAffineTransform {
162167
const ENCODING: Encoding = Encoding::Struct(
163168
"CGAffineTransform",

core-graphics-types/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// except according to those terms.
99

1010
extern crate core_foundation;
11+
#[cfg(feature = "objc2")]
1112
extern crate objc2;
1213

1314
pub mod base;

0 commit comments

Comments
 (0)