Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to construct a default Package #158

Open
jyn514 opened this issue Apr 14, 2021 · 1 comment
Open

Provide a way to construct a default Package #158

jyn514 opened this issue Apr 14, 2021 · 1 comment

Comments

@jyn514
Copy link
Collaborator

jyn514 commented Apr 14, 2021

Right now, I'm working with this monstrosity:

let package = serde_json::from_value(serde_json::json!({
                "packages": [
                    /*
                    {
                    "name": "doom-rustdoc",
                    "version": "1.0.0",
                    "id": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
                    "license": "Unlicense",
                    "license_file": null,
                    "description": "Doom running in Rustdoc",
                    "source": "registry+https://github.com/rust-lang/crates.io-index",
                    "dependencies": [],
                    "targets": [
                        {
                        "kind": [
                            "lib"
                        ],
                        "crate_types": [
                            "lib"
                        ],
                        "name": "doom-rustdoc",
                        //"src_path": "/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/doom-rustdoc-1.0.0/src/lib.rs",
                        "edition": "2018",
                        "doc": true,
                        "doctest": true,
                        "test": true
                        }
                    ],
                    "features": {},
                    //"manifest_path": "/home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/doom-rustdoc-1.0.0/Cargo.toml",
                    "metadata": null,
                    "publish": null,
                    "authors": [
                        //"Kestrer <kestrer.dev@gmail.com>"
                    ],
                    "categories": [],
                    "keywords": [],
                    "readme": null,
                    "repository": null,
                    "homepage": null,
                    "documentation": null,
                    "edition": "2018",
                    "links": null
                    },
                    */
                    {
                    "name": "hello-world",
                    "version": "0.1.0",
                    //"id": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)",
                    "license": null,
                    "license_file": null,
                    "description": null,
                    "source": null,
                    "dependencies": [
                        {
                        "name": "doom-rustdoc",
                        "source": "registry+https://github.com/rust-lang/crates.io-index",
                        "req": "^1",
                        "kind": null,
                        "rename": null,
                        "optional": false,
                        "uses_default_features": true,
                        "features": [],
                        "target": null,
                        "registry": null
                        }
                    ],
                    "targets": [
                        {
                        "kind": [
                            "bin"
                        ],
                        "crate_types": [
                            "bin"
                        ],
                        "name": "hello-world",
                        //"src_path": "/home/joshua/src/rust/hello-world/src/main.rs",
                        "edition": "2018",
                        "doc": true,
                        "doctest": false,
                        "test": true
                        }
                    ],
                    "features": {},
                    //"manifest_path": "/home/joshua/src/rust/hello-world/Cargo.toml",
                    "metadata": null,
                    "publish": null,
                    "authors": [],
                    "categories": [],
                    "keywords": [],
                    "readme": null,
                    "repository": null,
                    "homepage": null,
                    "documentation": null,
                    "edition": "2018",
                    "links": null
                    }
                ],
                "workspace_members": [
                    //"hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)"
                ],
                "resolve": {
                    "nodes": [
                    {
                        "id": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
                        "dependencies": [],
                        "deps": [],
                        "features": []
                    },
                    {
                        "id": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)",
                        "dependencies": [
                        "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
                        ],
                        "deps": [
                        {
                            "name": "doom_rustdoc",
                            "pkg": "doom-rustdoc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
                            "dep_kinds": [
                            {
                                "kind": null,
                                "target": null
                            }
                            ]
                        }
                        ],
                        "features": []
                    }
                    ],
                    "root": "hello-world 0.1.0 (path+file:///home/joshua/src/rust/hello-world)"
                },
                //"target_directory": "/home/joshua/.local/lib/cargo/target",
                //"version": 1,
                "workspace_root": "hello-world",
                "metadata": null
            }))
            .unwrap();

It would be nice to have a way to default construct a Package instead.

@jplatte
Copy link

jplatte commented Jun 23, 2022

I just had a look and found there is a builder feature that uses the derive_builder crate to generate a builder for some types like Package, does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants