Skip to content

Commit

Permalink
Implement TypeInfo for Arc (#180)
Browse files Browse the repository at this point in the history
* Implement `TypeInfo` for `Arc`

* Bump version to 2.7.0

* Update changelog

* Add link to the PR to the changelog

* Update UI test
  • Loading branch information
koute committed May 15, 2023
1 parent f6a6d83 commit 152ef28
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.7.0] - 2023-05-15

### Added
- `TypeInfo` is now implemented for `Arc` [(#180)](https://github.com/paritytech/scale-info/pull/180)

## [2.6.0] - 2023-04-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scale-info"
version = "2.6.0"
version = "2.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
rust-version = "1.60.0"
Expand Down
12 changes: 12 additions & 0 deletions src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::prelude::{
RangeInclusive,
},
string::String,
sync::Arc,
vec::Vec,
};

Expand Down Expand Up @@ -279,6 +280,17 @@ where
}
}

impl<T> TypeInfo for Arc<T>
where
T: TypeInfo + ?Sized + 'static,
{
type Identity = T;

fn type_info() -> Type {
Self::Identity::type_info()
}
}

impl<T> TypeInfo for &T
where
T: TypeInfo + ?Sized + 'static,
Expand Down
2 changes: 2 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cfg_if! {
num,
ops,
string,
sync,
vec,
};
} else {
Expand All @@ -46,6 +47,7 @@ cfg_if! {
collections,
format,
string,
sync,
vec,
};

Expand Down
2 changes: 1 addition & 1 deletion test_suite/tests/ui/fail_unions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ error[E0277]: the trait bound `Commonwealth: TypeInfo` is not satisfied
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 53 others
and $N others
note: required by a bound in `assert_type_info`
--> tests/ui/fail_unions.rs:11:24
|
Expand Down

0 comments on commit 152ef28

Please sign in to comment.