-
Notifications
You must be signed in to change notification settings - Fork 20
DOCSP-30557: FAQ #102
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
DOCSP-30557: FAQ #102
Conversation
ccho-mongodb
left a comment
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.
Plenty of helpful information here!
I left some comments mainly on making sure the information presented is clearly explained. Let me know if you have any questions.
ccho-mongodb
left a comment
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.
Added a few more suggestions and issues, but otherwise LGTM. If you would like me to take another look after making updates, let me know!
source/faq.txt
Outdated
| conversions between custom Rust types and BSON. You can install the ``serde`` | ||
| crate to access the functionality of the Serde framework. For instructions | ||
| on installing this crate, see `serde <https://crates.io/crates/serde>`__ in the | ||
| crates registry. |
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.
Suggestion:
I think it would be helpful to stay consistent with the terminology (whether "add the crate" or "install"). Based on
the prior comment and the first sentence of the next paragraph, perhaps this should be "add the crate".
source/faq.txt
Outdated
|
|
||
| After you add the crate to your application, you can model the documents in a collection | ||
| by using a custom type instead of a BSON document. The following example includes a ``derive`` | ||
| statement before the ``Vegetable`` struct definition, which instructs the driver to |
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.
Suggestion:
From the Derive page in Rust by Example, it seems like "derive" should be an "attribute" rather than "statement".
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.
good point - will fix in other Rust docs too
source/faq.txt
Outdated
| - ``Ok(T)``, which wraps the value of the result of the operation | ||
| - ``Err(E)``, which wraps an error value if the operation is unsuccessful |
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.
Issue:
The style guide on List Items provides specific guidance on list items that separate the initial term and information about it:
If you need to separate the initial term or phrase from the information that follows it, use a colon. However, if you don't need a separator, don't use one. (For an example of a list in which separators aren't necessary, see the list at the top of this topic.
Suggestion:
| - ``Ok(T)``, which wraps the value of the result of the operation | |
| - ``Err(E)``, which wraps an error value if the operation is unsuccessful | |
| - ``Ok(T)``: wraps the value of the result of the operation if the operation is successful | |
| - ``Err(E)`: wraps an error value if the operation is unsuccessful |
Applies to all similar instances.
source/faq.txt
Outdated
| To access the result of ``insert_one()``, you can use the ``?`` operator to unwrap its | ||
| return value. If the operation is successful, the ``?`` operator unwraps the ``InsertOneResult`` |
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.
Suggestion:
I think the first part of the sentence should directly introduce the rest of the sentence
In the current sentence, the first part mentions accessing the result and the rest of it explains only how to unwrap the return value.
| To access the result of ``insert_one()``, you can use the ``?`` operator to unwrap its | |
| return value. If the operation is successful, the ``?`` operator unwraps the ``InsertOneResult`` | |
| To access the unwrapped result of ``insert_one()``, use the ``?`` operator. If the operation is successful, the ``?`` operator unwraps the ``InsertOneResult`` |
source/faq.txt
Outdated
| Alternatively, you can create custom logic for handling the ``InsertOneResult`` value | ||
| depending on whether ``insert_one()`` returns the value wrapped in the ``Ok`` or the ``Err`` | ||
| variant. The following code uses the ``match`` keyword to process the ``insert_one()`` |
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.
Suggestion:
No change necessary, but I think this might be a more succinct way to present this sentence since Result (InsertOneResult, once that equivalence is added) was explained earlier:
| Alternatively, you can create custom logic for handling the ``InsertOneResult`` value | |
| depending on whether ``insert_one()`` returns the value wrapped in the ``Ok`` or the ``Err`` | |
| variant. The following code uses the ``match`` keyword to process the ``insert_one()`` | |
| Alternatively, you can create a conditional to handle the unwrapped values of ``InsertOneResult``. The following code uses the ``match`` keyword to process the ``insert_one()`` |
source/faq.txt
Outdated
| - `Result <https://doc.rust-lang.org/std/result/enum.Result.html>`__ | ||
| - `Option <https://doc.rust-lang.org/std/option/enum.Option.html>`__ | ||
| - `? Operator <https://doc.rust-lang.org/rust-by-example/std/result/question_mark.html>`__ | ||
| - `If Let <https://doc.rust-lang.org/book/ch06-03-if-let.html>`__ No newline at end of file |
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.
Suggestion:
I think this could be confusing since the keywords "if" and "let" are lowercase in their usage and the content of the link describes behavior of using two keywords in a pattern rather than adjacent to each other:
| - `If Let <https://doc.rust-lang.org/book/ch06-03-if-let.html>`__ | |
| - Control Flow with `if let <https://doc.rust-lang.org/book/ch06-03-if-let.html>`__ |
source/faq.txt
Outdated
| The ``Option`` enum can return the following variants: | ||
|
|
||
| - ``None``, which represents an empty value returned by an operation | ||
| - ``Some(T)``, which wraps a nonempty return value |
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.
Suggestion:
I think "nonempty" is usually spelled with a hyphen ("non-empty").
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.
Suggestion:
I think the placement of the Result example directly after this makes it awkward. Instead, perhaps placing this before the line that starts with "Some {+driver-short+} methods return an Option type, such as the read_concern()..." would make the information more organized and easier to locate.
source/faq.txt
Outdated
| } | ||
|
|
||
| You can then create a ``Collection`` instance with your custom struct type as its | ||
| generic type parameter. The following example instantiates the ``my_coll`` collection |
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.
Suggestion:
I think lowercase collection might imply a collection name rather than the Collection struct.
| generic type parameter. The following example instantiates the ``my_coll`` collection | |
| generic type parameter. The following example instantiates the ``my_coll`` Collection |
Alternatively, perhaps "variable" would be more conventional since this describes assignment rather than direct instantiation.
(cherry picked from commit bd90347)
(cherry picked from commit bd90347)
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-30557
Staging - https://preview-mongodbnorareidy.gatsbyjs.io/rust/DOCSP-30557-faq/faq/
Self-Review Checklist