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

New Chapter: Creating a library with cargo #292

Closed
wants to merge 3 commits into from

Conversation

steveklabnik
Copy link
Member

This is very early stages, bringing in some stuff from the Cargo guide. Not really ready for review.

- [Organizing your Public API](chXX-02-public-api.md)
- [Documentation](chXX-03-documentation.md)
- [Workspaces and Multiple Related Crates](chXX-04-workspaces.md)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's still a problem having to do with us changing this file on master since you opened this PR-- this chapter is duplicated 2 chapters below here, in the "Thinking in Rust" quarter. Was that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, no i messed up my rebase.

@@ -0,0 +1,175 @@
# Creating a Library with Cargo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this chapter could use an intro that talks about why you might want to write a library and publish it, so that people who have no interest in doing so could potentially skip or skim this chapter. This chapter helps with reading and contributing to other peoples' crates, so maybe mention that as well.

featured tool, and it has a lot to offer. In this chapter, we'll dig more into
the features of Cargo.

## Why does Cargo exist?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a lot of this section is covered in chapter 1, and there isn't much additional detail...

## `Cargo.toml` and `Cargo.lock`

`Cargo.toml` and `Cargo.lock` serve two different purposes. Before we talk
about them, here’s a summary:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a lot of this section is covered in chapter 2 when we pull in rand...

command-line tool or an application, check `Cargo.lock` into `git`. If you're
curious about why that is, see ["Why do binaries have `Cargo.lock` in version
control, but not libraries?" in the
FAQ](faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to have these sections in this chapter, detail about why you, as a library author, wouldn't want to check in your Cargo.lock is exactly the sort of detail we should be pulling in....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff like in this post would be awesome here imo: https://www.reddit.com/r/rust/comments/2ipwvx/why_cargolock/


## `cargo install`

## Extending Cargo with subcommands
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that cargo install and "Extending Cargo with subcommands" belong in this chapter, since they don't really have anything to do with creating a library. Working on an existing cargo package sounds like it would fit though!

@@ -0,0 +1,87 @@
# Crates.io

[crates.io] is the Rust community's central repository that serves
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was imagining this section talking more about how to publish a crate on crates.io-- what additional info in your Cargo.toml is recommended, how to think about your version numbers, what cargo publish does, etc. Not so much "go to crates.io and click on these things" since that might change, more like "here are the things you should think about when you publish a crate".

@@ -0,0 +1 @@
# Organizing your Public API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things I was thinking would be in this section:

  • pub means "these are the ways i expect users to use this library"
  • pub use for exporting a different structure than your internal structure for user convenience
  • Consequences of pub useing something from one of your dependencies (plz don't do it)
  • How do you know which version number to bump when you make which kinds of changes

@@ -0,0 +1 @@
# Documentation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things I was thinking would be in this section:

I wouldn't expect it to cover how to hosting docs online.

@@ -0,0 +1 @@
# Workspaces and Multiple Related Crates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect this section to talk about why you might want to use workspaces with your project: it's getting big, it's actually multiple separate crates, but they need to be developed and released together. I'd then expect explanation of how to specify workspaces in the various Cargo.tomls and how to structure the directories, basically the info from the crates.io docs. Also how workspaces interact with the cargo commands... looks like for now you have to do each manually?

@carols10cents
Copy link
Member

This article has some things that are relevant to this chapter: https://pascalhertleif.de/artikel/good-practices-for-writing-rust-libraries/

@steveklabnik
Copy link
Member Author

Not happy with this. Starting over.

@carols10cents carols10cents deleted the creating-a-library branch May 16, 2017 16:07
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

Successfully merging this pull request may close these issues.

2 participants