-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.2.0: make it work on the beta/stable channels.
This is a [breaking-change]. Traits being mopafied formerly needed to extend `std::any::Any`; now they need to extend `mopa::Any`. Users of `#![no_std]` will now need to enable the `no_std` feature on this crate. Users of this library formerly also needed `#![feature(core)]` on the crate; this is necessary no longer, because mopa works on Rust stable and beta.
- Loading branch information
1 parent
c1bbafd
commit 24f6c2d
Showing
7 changed files
with
154 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
language: rust | ||
rust: | ||
- nightly | ||
- beta | ||
#env: | ||
# global: | ||
# - secure: TODO | ||
#script: | ||
# - cargo build --verbose | ||
# - cargo test --verbose | ||
# - cargo doc --verbose | ||
script: | ||
- if [[ "$(rustc --version)" =~ -(dev|nightly) ]]; then cargo test --features no_std; else ! cargo test --features no_std; fi | ||
- cargo test | ||
# - cargo doc | ||
#after_script: | ||
# - ln -s target/doc doc | ||
# - curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "mopa" | ||
version = "0.1.8" | ||
version = "0.2.0" | ||
authors = ["Chris Morgan <[email protected]>"] | ||
description = "My Own Personal Any: get your own Any with additional functionality" | ||
#documentation = | ||
|
@@ -9,3 +9,6 @@ repository = "https://github.com/chris-morgan/mopa" | |
readme = "README.md" | ||
keywords = ["any", "macro"] | ||
license = "MIT/Apache-2.0" | ||
|
||
[features] | ||
no_std = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,47 @@ | ||
#![feature(lang_items, start, core, alloc, no_std)] | ||
#![no_std] | ||
// This example depends on the no_std feature being enabled on the crate; | ||
// without it, we have to go and chop everything off so that it can compile. | ||
// If you are basing something off this example, please note that all the `feature = "no_std"` | ||
// cfg-gating is a workaround for Cargo until https://github.com/rust-lang/cargo/issues/1570 lands. | ||
// Do not include it if you copy any code. | ||
|
||
#[macro_use] #[no_link] | ||
#![cfg_attr(feature = "no_std", feature(lang_items, start, core, alloc, no_std))] | ||
#![cfg_attr(feature = "no_std", no_std)] | ||
|
||
#[cfg(not(feature = "no_std"))] | ||
fn main() { } | ||
|
||
#[cfg(feature = "no_std")] | ||
#[macro_use] | ||
extern crate mopa; | ||
|
||
#[cfg(feature = "no_std")] | ||
extern crate core; | ||
#[cfg(feature = "no_std")] | ||
extern crate alloc; | ||
|
||
trait Panic { fn panic(&self) { } } | ||
#[cfg(feature = "no_std")] | ||
mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item { | ||
trait Panic { fn panic(&self) { } } | ||
|
||
trait PanicAny: Panic + core::any::Any { } | ||
trait PanicAny: Panic + ::mopa::Any { } | ||
|
||
mopafy!(PanicAny, core = core, alloc = alloc); | ||
mopafy!(PanicAny, core = core, alloc = alloc); | ||
|
||
impl Panic for i32 { } | ||
impl Panic for i32 { } | ||
|
||
impl<T: Panic + core::any::Any + 'static> PanicAny for T { } | ||
impl<T: Panic + ::mopa::Any + 'static> PanicAny for T { } | ||
|
||
#[start] | ||
fn start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let p: &PanicAny = &2; | ||
if p.is::<i32>() { | ||
0 | ||
} else { | ||
1 | ||
#[start] | ||
fn start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let p: &PanicAny = &2; | ||
if p.is::<i32>() { | ||
0 | ||
} else { | ||
1 | ||
} | ||
} | ||
} | ||
|
||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | ||
#[lang = "eh_personality"] extern fn eh_personality() {} | ||
#[lang = "panic_fmt"] extern fn panic_fmt() {} | ||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | ||
#[lang = "eh_personality"] extern fn eh_personality() {} | ||
#[lang = "panic_fmt"] extern fn panic_fmt() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
#![feature(lang_items, start, core, libc, no_std)] | ||
#![no_std] | ||
// This example depends on the no_std feature being enabled on the crate; | ||
// without it, we have to go and chop everything off so that it can compile. | ||
// If you are basing something off this example, please note that all the `feature = "no_std"` | ||
// cfg-gating is a workaround for Cargo until https://github.com/rust-lang/cargo/issues/1570 lands. | ||
// Do not include it if you copy any code. | ||
|
||
#[macro_use] #[no_link] | ||
|
||
#![cfg_attr(feature = "no_std", feature(lang_items, start, core, libc, no_std))] | ||
#![cfg_attr(feature = "no_std", no_std)] | ||
|
||
#[cfg(not(feature = "no_std"))] | ||
fn main() { } | ||
|
||
#[cfg(feature = "no_std")] | ||
#[macro_use] | ||
extern crate mopa; | ||
|
||
#[cfg(feature = "no_std")] | ||
extern crate core; | ||
#[cfg(feature = "no_std")] | ||
extern crate libc; | ||
|
||
trait Panic { fn panic(&self) { } } | ||
#[cfg(feature = "no_std")] | ||
mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item { | ||
trait Panic { fn panic(&self) { } } | ||
|
||
trait PanicAny: Panic + core::any::Any { } | ||
trait PanicAny: Panic + ::mopa::Any { } | ||
|
||
mopafy!(PanicAny, core = core); | ||
mopafy!(PanicAny, core = core); | ||
|
||
impl Panic for i32 { } | ||
impl Panic for i32 { } | ||
|
||
impl<T: Panic + core::any::Any + 'static> PanicAny for T { } | ||
impl<T: Panic + ::mopa::Any + 'static> PanicAny for T { } | ||
|
||
#[start] | ||
fn start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let p: &PanicAny = &2; | ||
if p.is::<i32>() { | ||
0 | ||
} else { | ||
1 | ||
#[start] | ||
fn start(_argc: isize, _argv: *const *const u8) -> isize { | ||
let p: &PanicAny = &2; | ||
if p.is::<i32>() { | ||
0 | ||
} else { | ||
1 | ||
} | ||
} | ||
} | ||
|
||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | ||
#[lang = "eh_personality"] extern fn eh_personality() {} | ||
#[lang = "panic_fmt"] extern fn panic_fmt() {} | ||
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} | ||
#[lang = "eh_personality"] extern fn eh_personality() {} | ||
#[lang = "panic_fmt"] extern fn panic_fmt() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.