Repository: wafflespeanut/paperclip
Pull request #283 (2020-12-28 23:15:10)

Update itertools requirement from 0.9 to 0.10
Updates the requirements on [itertools](https://github.com/bluss/rust-itertools) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md">itertools's changelog</a>.</em></p>
<blockquote>
<h2>0.10.0</h2>
<ul>
<li><strong>Increase minimum supported Rust version to 1.32.0</strong></li>
<li>Improve macro hygiene (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/507">#507</a>)</li>
<li>Add <code>Itertools::powerset</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/335">#335</a>)</li>
<li>Add <code>Itertools::sorted_unstable</code>, <code>Itertools::sorted_unstable_by</code>, and <code>Itertools::sorted_unstable_by_key</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/494">#494</a>)</li>
<li>Implement <code>Error</code> for <code>ExactlyOneError</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/484">#484</a>)</li>
<li>Undeprecate <code>Itertools::fold_while</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/476">#476</a>)</li>
<li>Tuple-related adapters work for tuples of arity up to 12 (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/475">#475</a>)</li>
<li><code>use_alloc</code> feature for users who have <code>alloc</code>, but not <code>std</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/474">#474</a>)</li>
<li>Add <code>Itertools::k_smallest</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/473">#473</a>)</li>
<li>Add <code>Itertools::into_grouping_map</code> and <code>GroupingMap</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/465">#465</a>)</li>
<li>Add <code>Itertools::into_grouping_map_by</code> and <code>GroupingMapBy</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/465">#465</a>)</li>
<li>Add <code>Itertools::counts</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/468">#468</a>)</li>
<li>Add implementation of <code>DoubleEndedIterator</code> for <code>Unique</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/442">#442</a>)</li>
<li>Add implementation of <code>DoubleEndedIterator</code> for <code>UniqueBy</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/442">#442</a>)</li>
<li>Add implementation of <code>DoubleEndedIterator</code> for <code>Zip</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/346">#346</a>)</li>
<li>Add <code>Itertools::multipeek</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/435">#435</a>)</li>
<li>Add <code>Itertools::dedup_with_count</code> and <code>DedupWithCount</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/423">#423</a>)</li>
<li>Add <code>Itertools::dedup_by_with_count</code> and <code>DedupByWithCount</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/423">#423</a>)</li>
<li>Add <code>Itertools::intersperse_with</code> and <code>IntersperseWith</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/381">#381</a>)</li>
<li>Add <code>Itertools::filter_ok</code> and <code>FilterOk</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Add <code>Itertools::filter_map_ok</code> and <code>FilterMapOk</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Deprecate <code>Itertools::fold_results</code>, use <code>Itertools::fold_ok</code> instead (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Deprecate <code>Itertools::map_results</code>, use <code>Itertools::map_ok</code> instead (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Deprecate <code>FoldResults</code>, use <code>FoldOk</code> instead (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Deprecate <code>MapResults</code>, use <code>MapOk</code> instead (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/377">#377</a>)</li>
<li>Add <code>Itertools::circular_tuple_windows</code> and <code>CircularTupleWindows</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/350">#350</a>)</li>
<li>Add <code>peek_nth</code> and <code>PeekNth</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/303">#303</a>)</li>
</ul>
<h2>0.9.0</h2>
<ul>
<li>Fix potential overflow in <code>MergeJoinBy::size_hint</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/385">#385</a>)</li>
<li>Add <code>derive(Clone)</code> where possible (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/382">#382</a>)</li>
<li>Add <code>try_collect</code> method (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/394">#394</a>)</li>
<li>Add <code>HomogeneousTuple</code> trait (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/389">#389</a>)</li>
<li>Fix <code>combinations(0)</code> and <code>combinations_with_replacement(0)</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/383">#383</a>)</li>
<li>Don't require <code>ParitalEq</code> to the <code>Item</code> of <code>DedupBy</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/397">#397</a>)</li>
<li>Implement missing specializations on the <code>PutBack</code> adaptor and on the <code>MergeJoinBy</code> iterator (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/372">#372</a>)</li>
<li>Add <code>position_*</code> methods (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/412">#412</a>)</li>
<li>Derive <code>Hash</code> for <code>EitherOrBoth</code> (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/417">#417</a>)</li>
<li>Increase minimum supported Rust version to 1.32.0</li>
</ul>
<h2>0.8.2</h2>
<ul>
<li>Use <code>slice::iter</code> instead of <code>into_iter</code> to avoid future breakage (<a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/378">#378</a>, by <a href="https://github.com/LukasKalbertodt">@LukasKalbertodt</a>)</li>
</ul>
<h2>0.8.1</h2>
<ul>
<li>Added a <a href="https://docs.rs/itertools/0.8.1/itertools/trait.Itertools.html#method.exactly_one"><code>.exactly_one()</code></a> iterator method that, on success, extracts the single value of an iterator ; by <a href="https://github.com/Xaeroxe">@Xaeroxe</a></li>
<li>Added combinatory iterator adaptors:
<ul>
<li>
<p><a href="https://docs.rs/itertools/0.8.1/itertools/trait.Itertools.html#method.permutations"><code>.permutations(k)</code></a>:</p>
<p><code>[0, 1, 2].iter().permutations(2)</code> yields</p>
</li>
</ul>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/rust-itertools/itertools/commit/4dac4c718895d8c0347d90be70f478673dd28193"><code>4dac4c7</code></a> (cargo-release) version 0.10.0</li>
<li><a href="https://github.com/rust-itertools/itertools/commit/8d27ab59a42929db188a8180d03dcb13717c0630"><code>8d27ab5</code></a> Merge <a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/465">#465</a></li>
<li><a href="https://github.com/rust-itertools/itertools/commit/5ad3e1ab76f97fcca078c0302bc472b0693c305c"><code>5ad3e1a</code></a> Merge <a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/507">#507</a></li>
<li><a href="https://github.com/rust-itertools/itertools/commit/79e39cbfed53317cf427578d24c29414a4d4bf4f"><code>79e39cb</code></a> Add tests for macros hygiene</li>
<li><a href="https://github.com/rust-itertools/itertools/commit/807a1ce2c5f713a46cc75afea14b067c26d10cd2"><code>807a1ce</code></a> Add $crate:: path to izip! and iproduct! inner calls</li>
<li><a href="https://github.com/rust-itertools/itertools/commit/00756e0f009e080b9e5abc862cbbbe81723cbde5"><code>00756e0</code></a> Merge <a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/473">#473</a></li>
<li><a href="https://github.com/rust-itertools/itertools/commit/130ffd309d140c1fec734b7003f357749c935413"><code>130ffd3</code></a> Merge <a href="https://github-redirect.dependabot.com/bluss/rust-itertools/issues/335">#335</a></li>
<li><a href="https://github.com/rust-itertools/itertools/commit/4183f2c6905f30b354ae7f278a4ded48cfad1e8a"><code>4183f2c</code></a> Update bors status</li>
<li><a href="https://github.com/rust-itertools/itertools/commit/67b7d745f1d39eadd7eb28ef9ea4b34ab64a119e"><code>67b7d74</code></a> more bors tweaks</li>
<li><a href="https://github.com/rust-itertools/itertools/commit/507d609d3559e47ed3d0aad9624c13e715269b49"><code>507d609</code></a> tweak workflow trigger</li>
<li>Additional commits viewable in <a href="https://github.com/bluss/rust-itertools/compare/v0.9.0...v0.10.0">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 62402870..d1202bd9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ env_logger = { version = "0.8", optional = true }
 git2 = { version = "0.13", optional = true }
 heck = { version = "0.3", optional = true }
 http = { version = "0.2", optional = true }
-itertools = "0.9"
+itertools = "0.10"
 log = { version = "0.4", optional = true }
 paperclip-actix = { path = "plugins/actix-web", version = "0.3.0", optional = true }
 paperclip-core = { path = "core", version = "0.3.0" }
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 934f640d..9e1c37f3 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -47,6 +47,9 @@ struct Opt {
     /// Emit CLI target instead.
     #[structopt(long = "cli")]
     cli: bool,
+    /// Do not make the crate a root crate.
+    #[structopt(long = "no-root")]
+    no_root: bool,
     /// Name of the crate. If this is not specified, then the name of the
     /// working directory is assumed to be crate name.
     #[structopt(long = "name")]
@@ -83,6 +86,8 @@ fn parse_args_and_run() -> Result<(), Error> {
         meta.version = opt.version;
     }
 
+    meta.no_root = opt.no_root;
+
     state.set_meta(meta);
     let emitter = DefaultEmitter::from(state);
     emitter.generate(&spec)
diff --git a/src/build/manifest.hbs b/src/build/manifest.hbs
index 266c846f..df1348cb 100644
--- a/src/build/manifest.hbs
+++ b/src/build/manifest.hbs
@@ -39,4 +39,6 @@ reqwest = \{ version = "0.10", features = ["stream", "json", "native-tls"] }
 tokio = \{ version = "0.3", features = ["fs", "io-util"] }
 reqwest = \{ version = "0.10", features = ["stream", "json"] }
 {{ endif }}
+{{ if not no_root -}}
 [workspace]
+{{- endif }}
diff --git a/src/v2/codegen/mod.rs b/src/v2/codegen/mod.rs
index affd684d..fec431d8 100644
--- a/src/v2/codegen/mod.rs
+++ b/src/v2/codegen/mod.rs
@@ -64,6 +64,8 @@ pub struct CrateMeta {
     pub authors: Option<Vec<String>>,
     /// Whether we're planning to emit a lib, app or module.
     pub mode: EmitMode,
+    /// Whether or not to make this a root crate.
+    pub no_root: bool,
     // Marker to avoid potential breakage when more public fields come in.
     _marker: (),
 }
diff --git a/src/v2/codegen/state.rs b/src/v2/codegen/state.rs
index 20599b35..fe064721 100644
--- a/src/v2/codegen/state.rs
+++ b/src/v2/codegen/state.rs
@@ -374,6 +374,15 @@ pub mod util {
             .unwrap_or(false))
     }
 
+    fn no_root(&self) -> Result<bool, Error> {
+        Ok(self
+            .infer_crate_meta()?
+            .borrow()
+            .as_ref()
+            .map(|m| m.no_root)
+            .unwrap_or(true))
+    }
+
     /// Normalized module prefix used by codegen.
     fn normalized_mod_prefix(&self) -> String {
         format!("{}::", self.mod_prefix.trim_matches(':'))
@@ -420,6 +429,7 @@ impl EmitterState {
     fn create_manifest(&self) -> Result<(), Error> {
         let mut man_path = self.root_module_path();
         let is_cli = self.is_cli()?;
+        let no_root = self.no_root()?;
         man_path.set_file_name("Cargo.toml");
 
         let cm = self.infer_crate_meta()?;
@@ -437,6 +447,7 @@ impl EmitterState {
                     version: &format!("{:?}", meta.version.as_ref().unwrap()),
                     authors: &format!("{:?}", meta.authors.as_ref().unwrap()),
                     is_cli,
+                    no_root,
                 },
             )?;
 
@@ -572,6 +583,7 @@ struct ManifestContext<'a> {
     version: &'a str,
     authors: &'a str,
     is_cli: bool,
+    no_root: bool,
 }
 
 #[derive(serde::Serialize)]


Test patch:
diff --git a/tests/snapshots/test_codegen__tests__test_pet__no_root__Cargo.toml.snap b/tests/snapshots/test_codegen__tests__test_pet__no_root__Cargo.toml.snap
new file mode 100644
index 00000000..e8f542cf
--- /dev/null
+++ b/tests/snapshots/test_codegen__tests__test_pet__no_root__Cargo.toml.snap
@@ -0,0 +1,35 @@
+---
+source: tests/test_codegen.rs
+expression: data
+---
+[package]
+name = "no_root"
+version = "0.1.0"
+authors = ["Me <me@example.com>"]
+edition = "2018"
+
+[lib]
+path = "lib.rs"
+
+[dependencies]
+async-trait = "0.1"
+bytes = "0.5"
+thiserror = "1.0"
+futures = "0.3"
+http = "0.2"
+lazy_static = "1.4"
+log = "0.4"
+mime = { git = "https://github.com/hyperium/mime" }
+mime_guess = "2.0"
+parking_lot = "0.11"
+serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
+serde_yaml = "0.8"
+tokio-util = { version = "0.4", features = ["codec"] }
+url = "2.1"
+
+tokio = { version = "0.3", features = ["fs", "io-util"] }
+reqwest = { version = "0.10", features = ["stream", "json"] }
+
+
+
diff --git a/tests/test_codegen.rs b/tests/test_codegen.rs
index 0e34429b..ad6c423b 100644
--- a/tests/test_codegen.rs
+++ b/tests/test_codegen.rs
@@ -30,6 +30,19 @@ static CODEGEN_PET_LIB: Lazy<()> = Lazy::new(|| {
     let emitter = DefaultEmitter::from(state);
     emitter.generate(&PET_SCHEMA).expect("codegen");
 });
+static CODEGEN_PET_LIB_NO_ROOT: Lazy<()> = Lazy::new(|| {
+    let mut state = EmitterState::default();
+    state.working_dir = ROOT.clone();
+    state.working_dir.push("tests/test_pet/no_root");
+    let mut meta = CrateMeta::default();
+    meta.authors = Some(vec!["Me <me@example.com>".into()]);
+    meta.mode = EmitMode::Crate;
+    meta.no_root = true;
+    state.set_meta(meta);
+
+    let emitter = DefaultEmitter::from(state);
+    emitter.generate(&PET_SCHEMA).expect("codegen");
+});
 static CODEGEN_PET_CLI: Lazy<()> = Lazy::new(|| {
     let mut state = EmitterState::default();
     state.working_dir = (&*ROOT).into();
@@ -91,6 +104,7 @@ static CODEGEN: Lazy<()> = Lazy::new(|| {
         .filter(Some("paperclip"), log::LevelFilter::Info)
         .init();
     Lazy::force(&CODEGEN_PET_LIB);
+    Lazy::force(&CODEGEN_PET_LIB_NO_ROOT);
     Lazy::force(&CODEGEN_PET_CLI);
     Lazy::force(&CODEGEN_K8S_LIB);
     Lazy::force(&CODEGEN_K8S_CLI);
@@ -112,6 +126,11 @@ mod tests_pet {
         assert_file("tests/test_pet/lib.rs");
     }
 
+    #[test]
+    fn test_no_root_manifest() {
+        assert_file("tests/test_pet/no_root/Cargo.toml");
+    }
+
     #[test]
     fn test_manifest() {
         assert_file("tests/test_pet/Cargo.toml");