Skip to content

Commit

Permalink
Merge pull request #7 from alecmocatta/v0.2.0
Browse files Browse the repository at this point in the history
Switch to using pointers everywhere with arbitrary_self_types
  • Loading branch information
alecmocatta authored Oct 18, 2019
2 parents da43366 + 5e74b50 commit 998f4f6
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 146 deletions.
10 changes: 4 additions & 6 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ pull_request_rules:
conditions:
- base=master
- status-success=tests
- label!=work-in-progress
- "label!=work in progress"
- "#approved-reviews-by>=1"
- "#review-requested=0"
- "#changes-requested-reviews-by=0"
- "#commented-reviews-by=0"
actions:
merge:
method: merge
Expand All @@ -17,11 +16,10 @@ pull_request_rules:
conditions:
- base=master
- status-success=tests
- label!=work-in-progress
- "label!=work in progress"
- author=alecmocatta # https://github.com/Mergifyio/mergify-engine/issues/451
- "#review-requested=0"
- "#changes-requested-reviews-by=0"
- "#commented-reviews-by=0"
actions:
merge:
method: merge
Expand All @@ -36,10 +34,10 @@ pull_request_rules:
- "title~=^WIP: .*"
actions:
label:
add: ["work-in-progress"]
add: ["work in progress"]
- name: auto remove wip label
conditions:
- "-title~=^WIP: .*"
actions:
label:
remove: ["work-in-progress"]
remove: ["work in progress"]
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metatype"
version = "0.1.2"
version = "0.2.0"
license = "MIT OR Apache-2.0"
authors = ["Alec Mocatta <alec@mocatta.net>"]
categories = ["development-tools","rust-patterns"]
Expand All @@ -10,7 +10,7 @@ Helper methods to determine whether a type is `TraitObject`, `Slice` or `Concret
"""
repository = "https://github.com/alecmocatta/metatype"
homepage = "https://github.com/alecmocatta/metatype"
documentation = "https://docs.rs/metatype/0.1.2"
documentation = "https://docs.rs/metatype/0.2.0"
readme = "README.md"
edition = "2018"

Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![MIT / Apache 2.0 licensed](https://img.shields.io/crates/l/metatype.svg?maxAge=2592000)](#License)
[![Build Status](https://dev.azure.com/alecmocatta/metatype/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/metatype/_build/latest?branchName=master)

[Docs](https://docs.rs/metatype/0.1.2)
[Docs](https://docs.rs/metatype/0.2.0)

Helper methods to determine whether a type is `TraitObject`, `Slice` or `Concrete`, and work with them respectively.

Expand All @@ -16,24 +16,23 @@ assert_eq!(any::Any::METATYPE, MetaType::TraitObject);
assert_eq!(<[u8]>::METATYPE, MetaType::Slice);

let a: Box<usize> = Box::new(123);
assert_eq!((&*a).meta_type(), MetaType::Concrete);
let a: Box<any::Any> = a;
assert_eq!((&*a).meta_type(), MetaType::TraitObject);
assert_eq!(Type::meta_type(&*a), MetaType::Concrete);
let a: Box<dyn any::Any> = a;
assert_eq!(Type::meta_type(&*a), MetaType::TraitObject);

let a = [123,456];
assert_eq!(a.meta_type(), MetaType::Concrete);
assert_eq!(Type::meta_type(&a), MetaType::Concrete);
let a: &[i32] = &a;
assert_eq!(a.meta_type(), MetaType::Slice);
assert_eq!(Type::meta_type(a), MetaType::Slice);

let a: Box<any::Any> = Box::new(123);
// https://github.com/rust-lang/rust/issues/50318
// let meta: TraitObject = (&*a).meta();
// println!("vtable: {:?}", meta.vtable);
let a: Box<dyn any::Any> = Box::new(123);
let meta: TraitObject = type_coerce(Type::meta(&*a));
println!("vtable: {:?}", meta.vtable);
```

## Note

This currently requires Rust nightly for the `raw` and `specialization` features.
This currently requires Rust nightly for the `raw`, `specialization` and `arbitrary_self_types` features.

## License
Licensed under either of
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
endpoint: alecmocatta
default:
rust_toolchain: nightly
rust_lint_toolchain: nightly-2019-07-19
rust_lint_toolchain: nightly-2019-10-17
rust_flags: ''
rust_features: ''
rust_target_check: ''
Expand Down
Loading

0 comments on commit 998f4f6

Please sign in to comment.