Skip to content

Commit

Permalink
Bump edition to 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jun 2, 2021
1 parent 458ed98 commit fcfe0de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "objc_exception"
version = "0.1.2"
authors = ["Steven Sheldon"]
edition = "2018"

description = "Rust interface for Objective-C's throw and try/catch statements."
keywords = ["objective-c", "osx", "ios"]
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern { }

extern {
fn RustObjCExceptionThrow(exception: *mut c_void);
fn RustObjCExceptionTryCatch(try: extern fn(*mut c_void),
fn RustObjCExceptionTryCatch(r#try: extern fn(*mut c_void),
context: *mut c_void, error: *mut *mut c_void) -> u8; // std::os::raw::c_uchar
}

Expand Down Expand Up @@ -64,7 +64,7 @@ unsafe fn try_no_ret<F>(closure: F) -> Result<(), *mut Exception>
///
/// Unsafe because this encourages unwinding through the closure from
/// Objective-C, which is not safe.
pub unsafe fn try<F, R>(closure: F) -> Result<R, *mut Exception>
pub unsafe fn r#try<F, R>(closure: F) -> Result<R, *mut Exception>
where F: FnOnce() -> R {
let mut value = None;
let result = {
Expand All @@ -82,13 +82,13 @@ mod tests {
use alloc::string::ToString;
use core::ptr;

use super::{throw, try};
use super::{r#try, throw};

#[test]
fn test_try() {
unsafe {
let s = "Hello".to_string();
let result = try(move || {
let result = r#try(move || {
if s.len() > 0 {
throw(ptr::null_mut());
}
Expand All @@ -97,7 +97,7 @@ mod tests {
assert!(result.unwrap_err() == ptr::null_mut());

let mut s = "Hello".to_string();
let result = try(move || {
let result = r#try(move || {
s.push_str(", World!");
s
});
Expand Down

0 comments on commit fcfe0de

Please sign in to comment.