Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Jan 3, 2024
1 parent 56dec8c commit a9e91b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
11 changes: 3 additions & 8 deletions cidre/src/ns/dictionary.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use std::marker::PhantomData;

use crate::{
arc, define_cls, ns,
objc::{self, Obj},
};

use super::Class;
use crate::{arc, define_cls, ns, objc, objc::Obj};

#[derive(Debug)]
#[repr(transparent)]
Expand Down Expand Up @@ -142,8 +137,8 @@ impl<K: Obj, V: Obj> DictionaryMut<K, V> {

#[link(name = "ns", kind = "static")]
extern "C" {
static NS_DICTIONARY: &'static Class<Dictionary<ns::Id, ns::Id>>;
static NS_MUTABLE_DICTIONARY: &'static Class<DictionaryMut<ns::Id, ns::Id>>;
static NS_DICTIONARY: &'static ns::Class<Dictionary<ns::Id, ns::Id>>;
static NS_MUTABLE_DICTIONARY: &'static ns::Class<DictionaryMut<ns::Id, ns::Id>>;
}

#[cfg(test)]
Expand Down
18 changes: 11 additions & 7 deletions cidre/src/ns/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ pub enum Encoding {
MacOSRoman = 30,
}

define_obj_type!(pub String(ns::Id), NS_STRING);
define_obj_type!(pub StringMut(String), NS_MUTABLE_STRING);
define_obj_type!(
#[doc(alias = "NSString")]
pub String(ns::Id), NS_STRING
);

define_obj_type!(
#[doc(alias = "NSMutableString")]
pub StringMut(String), NS_MUTABLE_STRING
);

impl arc::A<String> {
#[objc::msg_send(initWithBytes:length:encoding:)]
Expand Down Expand Up @@ -250,10 +257,7 @@ impl fmt::Display for String {

#[cfg(test)]
mod tests {
use crate::{
ns::{self, try_catch},
objc::ar_pool,
};
use crate::{ns, objc::ar_pool};

#[test]
fn basics() {
Expand Down Expand Up @@ -282,7 +286,7 @@ mod tests {
// let sub = &s[3..4];
// assert_eq!(sub.to_i32(), 5);

let r = try_catch(|| s.substring(1..10));
let r = ns::try_catch(|| s.substring(1..10));
assert!(r.is_err());

let _l = s.lowercased();
Expand Down

0 comments on commit a9e91b9

Please sign in to comment.