Skip to content

Commit 0496884

Browse files
authored
[14/n] temporary workaround for cargo-sync-rdme bug
While we wait for gifnksm/cargo-sync-rdme#514 to be merged upstream and make its way into a release, here is a temporary workaround. Reviewers: andrewjstone Reviewed By: andrewjstone Pull Request: #45
1 parent 5821e49 commit 0496884

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

.github/workflows/ci.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ jobs:
1818
with:
1919
components: rustfmt, clippy
2020
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
21-
- name: Install cargo-sync-rdme and just
21+
- name: Install just and cargo-hack
2222
uses: taiki-e/install-action@v2
2323
with:
24-
tool: cargo-sync-rdme,just,cargo-hack
24+
tool: just,cargo-hack
25+
- name: Install fork of cargo-sync-rdme
26+
# This is a fork of cargo-sync-rdme with a fix for
27+
# https://github.com/gifnksm/cargo-sync-rdme/pull/514 included -- remove
28+
# once merged upstream.
29+
run: |
30+
curl -LsSf https://github.com/sunshowers/cargo-sync-rdme/releases/download/v0.4.2-b.1%2Bsunshowers/cargo-sync-rdme-v0.4.2-b.1+sunshowers-x86_64-unknown-linux-gnu.tar.gz \
31+
| tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
2532
- name: Lint (clippy)
2633
run: just powerset clippy --all-targets
2734
- name: Lint (rustfmt)

Justfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ rustdoc *args:
1717

1818
# Generate README.md files using `cargo-sync-rdme`.
1919
generate-readmes:
20+
# Please install via cargo install --locked --git https://github.com/sunshowers/cargo-sync-rdme for now.
2021
cargo sync-rdme --toolchain nightly --workspace --all-features

daft/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ notion of a type for which two members can be simultaneously compared.
2727
use daft::{Diffable, Leaf};
2828

2929
// Annotate your struct with `#[derive(Diffable)]`:
30+
#[derive(Diffable)]
3031
struct MyStruct {
3132
a: i32,
3233
b: String,
3334
}
3435

3536
// This generates a type called MyStructDiff, which looks like:
37+
#[automatically_derived]
3638
struct MyStructDiff<'daft> {
3739
a: Leaf<&'daft i32>,
3840
b: Leaf<&'daft str>,
@@ -95,6 +97,7 @@ assert_eq!(diff.before, Some(&1));
9597
assert_eq!(diff.after, Some(&2));
9698

9799
// Automatically derived enums also use Leaf:
100+
#[derive(Debug, PartialEq, Eq, Diffable)]
98101
enum MyEnum {
99102
A(i32),
100103
B(String),
@@ -261,6 +264,7 @@ Tuple-like structs produce tuple-like diff structs:
261264
use daft::Diffable;
262265
use std::collections::BTreeMap;
263266

267+
#[derive(Diffable)]
264268
struct MyTuple(BTreeMap<i32, &'static str>, i32);
265269

266270
let before = MyTuple(BTreeMap::new(), 1);
@@ -278,6 +282,8 @@ An example with `#[daft(leaf)]` on **structs**:
278282
````rust
279283
use daft::{Diffable, Leaf};
280284

285+
#[derive(Diffable)]
286+
#[daft(leaf)]
281287
struct MyStruct {
282288
a: i32,
283289
}
@@ -296,13 +302,16 @@ An example with `#[daft(leaf)]` on **struct fields**:
296302
use daft::{Diffable, Leaf};
297303

298304
// A simple struct that implements Diffable.
305+
#[derive(Debug, PartialEq, Eq, Diffable)]
299306
struct InnerStruct {
300307
text: &'static str,
301308
}
302309

303310
// A struct that does not implement Diffable.
311+
#[derive(Debug, PartialEq, Eq)]
304312
struct PlainStruct(usize);
305313

314+
#[derive(Diffable)]
306315
struct OuterStruct {
307316
// Ordinarily, InnerStruct would be diffed recursively, but
308317
// with #[daft(leaf)], it is treated as a leaf node.
@@ -383,13 +392,15 @@ outlive it.
383392
````rust
384393
use daft::Diffable;
385394

395+
#[derive(Diffable)]
386396
struct BorrowedData<'a, 'b, T: Diffable + ?Sized> {
387397
a: &'a str,
388398
b: &'b T,
389399
// TODO: example with daft(leaf)
390400
}
391401

392402
// This generates a struct that looks like:
403+
#[automatically_derived]
393404
struct BorrowedDataDiff<'daft, 'a: 'daft, 'b: 'daft, T: ?Sized + 'daft> {
394405
a: Leaf<'daft, &'a str>,
395406
b: T::Diff<'daft>,

0 commit comments

Comments
 (0)