Skip to content

Commit 56b82ad

Browse files
committed
Merge branch 'master' into chore/update-changelog
2 parents 92e314d + 2a97b87 commit 56b82ad

File tree

15 files changed

+598
-378
lines changed

15 files changed

+598
-378
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Continuous integration
7+
8+
env:
9+
RUSTFLAGS: '--deny warnings'
10+
11+
jobs:
12+
ci-linux:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
# All generated code should be running on stable now
17+
rust: [stable]
18+
19+
# The default target we're compiling on and for
20+
TARGET: [x86_64-unknown-linux-gnu, thumbv6m-none-eabi, thumbv7m-none-eabi]
21+
22+
include:
23+
# Test MSRV
24+
- rust: 1.40.0
25+
TARGET: x86_64-unknown-linux-gnu
26+
27+
# Test nightly but don't fail
28+
- rust: nightly
29+
experimental: true
30+
TARGET: x86_64-unknown-linux-gnu
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
- uses: actions-rs/toolchain@v1
35+
with:
36+
profile: minimal
37+
toolchain: ${{ matrix.rust }}
38+
target: ${{ matrix.TARGET }}
39+
override: true
40+
- uses: actions-rs/cargo@v1
41+
with:
42+
command: build
43+
args: --target=${{ matrix.TARGET }}
44+
- uses: actions-rs/cargo@v1
45+
if: ${{ contains(matrix.TARGET, 'x86_64') }}
46+
with:
47+
command: test
48+
args: --target=${{ matrix.TARGET }}

.github/workflows/clippy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Clippy check
7+
jobs:
8+
clippy_check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: stable
16+
override: true
17+
components: clippy
18+
- uses: actions-rs/clippy-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rustfmt.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Code formatting check
7+
8+
jobs:
9+
fmt:
10+
name: Rustfmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
components: rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

ci/after_success.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

ci/install.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

ci/script.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly
1+
stable

src/de/enum_.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,56 @@ impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
5353
Err(Error::InvalidType)
5454
}
5555
}
56+
57+
pub(crate) struct VariantAccess<'a, 'b> {
58+
de: &'a mut Deserializer<'b>,
59+
}
60+
61+
impl<'a, 'b> VariantAccess<'a, 'b> {
62+
pub(crate) fn new(de: &'a mut Deserializer<'b>) -> Self {
63+
VariantAccess { de }
64+
}
65+
}
66+
67+
impl<'a, 'de> de::EnumAccess<'de> for VariantAccess<'a, 'de> {
68+
type Error = Error;
69+
type Variant = Self;
70+
71+
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self)>
72+
where
73+
V: de::DeserializeSeed<'de>,
74+
{
75+
let variant = seed.deserialize(&mut *self.de)?;
76+
self.de.parse_object_colon()?;
77+
Ok((variant, self))
78+
}
79+
}
80+
81+
impl<'de, 'a> de::VariantAccess<'de> for VariantAccess<'a, 'de> {
82+
type Error = Error;
83+
84+
fn unit_variant(self) -> Result<()> {
85+
de::Deserialize::deserialize(self.de)
86+
}
87+
88+
fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value>
89+
where
90+
T: de::DeserializeSeed<'de>,
91+
{
92+
seed.deserialize(self.de)
93+
}
94+
95+
fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value>
96+
where
97+
V: de::Visitor<'de>,
98+
{
99+
de::Deserializer::deserialize_seq(self.de, visitor)
100+
}
101+
102+
fn struct_variant<V>(self, fields: &'static [&'static str], visitor: V) -> Result<V::Value>
103+
where
104+
V: de::Visitor<'de>,
105+
{
106+
de::Deserializer::deserialize_struct(self.de, "", fields, visitor)
107+
}
108+
}

0 commit comments

Comments
 (0)