-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Added information about examples as libraries to the documentation #3582
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
Added information about examples as libraries to the documentation #3582
Conversation
@alexcrichton, |
@@ -451,13 +451,19 @@ To structure your code after you've created the files and folders for your proje | |||
Files located under `examples` are example uses of the functionality provided by | |||
the library. When compiled, they are placed in the `target/examples` directory. | |||
|
|||
They must compile as executables (with a `main()` function) and load in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this paragraph could be:
They can compile as executables (with a
main()
function) or libraries and pull in the main library throughextern crate <library-name>
. Examples are compiled when you run your tests to prevent them from bitrotting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcrichton,
I am not a native speaker, so if you say so I will change.
I am curious.
Why my sentence is invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh there wasn't anything wrong with it, it just seemed to not flow well having two sentences starting with 'They' back-to-back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on updating this paragraph?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already updated it.
<example-name>`. | ||
|
||
Specify `crate-type` to make an example be compiled as a library: | ||
```toml | ||
[[example.example]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just [[example]]
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it isn't.
.example
means an example with name example
.
Should I change it to .foo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok well as the author of Cargo and implementor of this feature I'm saying [[example.example]]
is invalid. The correct syntax is [[example]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcrichton,
Yes, indeed.
I am sorry.
I saw that somewhere. I will change that.
[ci skip]
<example-name>`. | ||
|
||
Specify `crate-type` to make an example be compiled as a library: | ||
```toml | ||
[[example.foo]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The '.foo' here needs to be removed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that I am stupid.
Sorry.
@bors: r+ |
📌 Commit 5caee7f has been approved by |
…es, r=alexcrichton Added information about examples as libraries to the documentation [Allow examples to be library](#3556) has been committed. The PR adds information to the documentation.
@alexcrichton, |
☀️ Test successful - status-appveyor, status-travis |
Allow examples to be library has been committed.
The PR adds information to the documentation.