History

fix docs (#331)

Sebastian Thiel committed 4 years ago

Commit 21864561 parent f7be3b04 files · +13 −13Browse files

Unified · Split

4 files
  1. git-config/src/file/impls.rs +1 −1
  2. git-config/src/lib.rs +1 −1
  3. git-config/src/parse/events.rs +9 −9
  4. git-config/src/parse/mod.rs +2 −2
git-config/src/file/impls.rs+1−1
@@ -7,7 +7,7 @@ impl<'a> TryFrom<&'a str> for File<'a> { · 6 unmodified lines
7 type Error = parse::Error<'a>;7 type Error = parse::Error<'a>;
8 8
9 /// Convenience constructor. Attempts to parse the provided string into a9 /// Convenience constructor. Attempts to parse the provided string into a
10 /// [`File`]. See [`State::from_str()`] for more information.10 /// [`File`]. See [`Events::from_str()`][crate::parse::Events::from_str()] for more information.
11 fn try_from(s: &'a str) -> Result<File<'a>, Self::Error> {11 fn try_from(s: &'a str) -> Result<File<'a>, Self::Error> {
12 parse::Events::from_str(s).map(Self::from)12 parse::Events::from_str(s).map(Self::from)
13 }13 }
git-config/src/lib.rs+1−1
@@ -43,7 +43,7 @@ · 42 unmodified lines
43//! [`git-config` files]: https://git-scm.com/docs/git-config#_configuration_file43//! [`git-config` files]: https://git-scm.com/docs/git-config#_configuration_file
44//! [INI file format]: https://en.wikipedia.org/wiki/INI_file44//! [INI file format]: https://en.wikipedia.org/wiki/INI_file
45//! [`File`]: crate::File45//! [`File`]: crate::File
46//! [`parse::State`]: crate::parse::State46//! [`parse::State`]: crate::parse::Events
47//! [`value`]: crate::value47//! [`value`]: crate::value
48//! [`nom`]: https://github.com/Geal/nom48//! [`nom`]: https://github.com/Geal/nom
49//!49//!
git-config/src/parse/events.rs+9−9
@@ -218,7 +218,7 @@ pub struct Events<'a> { · 217 unmodified lines
218 218
219impl Events<'static> {219impl Events<'static> {
220 /// Parses a git config located at the provided path. On success, returns a220 /// Parses a git config located at the provided path. On success, returns a
221 /// [`State`] that provides methods to accessing leading comments and sections221 /// [`Events`] that provides methods to accessing leading comments and sections
222 /// of a `git-config` file and can be converted into an iterator of [`Event`]222 /// of a `git-config` file and can be converted into an iterator of [`Event`]
223 /// for higher level processing.223 /// for higher level processing.
224 ///224 ///
@@ -239,8 +239,8 @@ impl Events<'static> { · 14 unmodified lines
239 crate::parse::nom::from_bytes_owned(&bytes).map_err(from_path::Error::Parse)239 crate::parse::nom::from_bytes_owned(&bytes).map_err(from_path::Error::Parse)
240 }240 }
241 241
242 /// Parses the provided bytes, returning an [`State`] that contains allocated242 /// Parses the provided bytes, returning an [`Events`] that contains allocated
243 /// and owned events. This is similar to [`State::from_bytes()`], but performance243 /// and owned events. This is similar to [`Events::from_bytes()`], but performance
244 /// is degraded as it requires allocation for every event. However, this permits244 /// is degraded as it requires allocation for every event. However, this permits
245 /// the reference bytes to be dropped, allowing the parser to be passed around245 /// the reference bytes to be dropped, allowing the parser to be passed around
246 /// without lifetime worries.246 /// without lifetime worries.
@@ -258,7 +258,7 @@ impl Events<'static> { · 11 unmodified lines
258 258
259impl<'a> Events<'a> {259impl<'a> Events<'a> {
260 /// Attempt to zero-copy parse the provided `&str`. On success, returns a260 /// Attempt to zero-copy parse the provided `&str`. On success, returns a
261 /// [`State`] that provides methods to accessing leading comments and sections261 /// [`Events`] that provides methods to accessing leading comments and sections
262 /// of a `git-config` file and can be converted into an iterator of [`Event`]262 /// of a `git-config` file and can be converted into an iterator of [`Event`]
263 /// for higher level processing.263 /// for higher level processing.
264 ///264 ///
@@ -273,7 +273,7 @@ impl<'a> Events<'a> { · 8 unmodified lines
273 }273 }
274 274
275 /// Attempt to zero-copy parse the provided bytes. On success, returns a275 /// Attempt to zero-copy parse the provided bytes. On success, returns a
276 /// [`State`] that provides methods to accessing leading comments and sections276 /// [`Events`] that provides methods to accessing leading comments and sections
277 /// of a `git-config` file and can be converted into an iterator of [`Event`]277 /// of a `git-config` file and can be converted into an iterator of [`Event`]
278 /// for higher level processing.278 /// for higher level processing.
279 ///279 ///
@@ -290,7 +290,7 @@ impl<'a> Events<'a> { · 10 unmodified lines
290 290
291impl<'a> Events<'a> {291impl<'a> Events<'a> {
292 /// Returns the leading events (any comments, whitespace, or newlines before292 /// Returns the leading events (any comments, whitespace, or newlines before
293 /// a section) from the parser. Consider [`State::take_frontmatter`] if293 /// a section) from the parser. Consider [`Events::take_frontmatter`] if
294 /// you need an owned copy only once. If that function was called, then this294 /// you need an owned copy only once. If that function was called, then this
295 /// will always return an empty slice.295 /// will always return an empty slice.
296 #[must_use]296 #[must_use]
@@ -300,14 +300,14 @@ impl<'a> Events<'a> { · 3 unmodified lines
300 300
301 /// Takes the leading events (any comments, whitespace, or newlines before301 /// Takes the leading events (any comments, whitespace, or newlines before
302 /// a section) from the parser. Subsequent calls will return an empty vec.302 /// a section) from the parser. Subsequent calls will return an empty vec.
303 /// Consider [`State::frontmatter`] if you only need a reference to the303 /// Consider [`Events::frontmatter`] if you only need a reference to the
304 /// frontmatter304 /// frontmatter
305 pub fn take_frontmatter(&mut self) -> Vec<Event<'a>> {305 pub fn take_frontmatter(&mut self) -> Vec<Event<'a>> {
306 std::mem::take(&mut self.frontmatter)306 std::mem::take(&mut self.frontmatter)
307 }307 }
308 308
309 /// Returns the parsed sections from the parser. Consider309 /// Returns the parsed sections from the parser. Consider
310 /// [`State::take_sections`] if you need an owned copy only once. If that310 /// [`Events::take_sections`] if you need an owned copy only once. If that
311 /// function was called, then this will always return an empty slice.311 /// function was called, then this will always return an empty slice.
312 #[must_use]312 #[must_use]
313 pub fn sections(&self) -> &[Section<'a>] {313 pub fn sections(&self) -> &[Section<'a>] {
@@ -315,7 +315,7 @@ impl<'a> Events<'a> { · 1 unmodified line
315 }315 }
316 316
317 /// Takes the parsed sections from the parser. Subsequent calls will return317 /// Takes the parsed sections from the parser. Subsequent calls will return
318 /// an empty vec. Consider [`State::sections`] if you only need a reference318 /// an empty vec. Consider [`Events::sections`] if you only need a reference
319 /// to the comments.319 /// to the comments.
320 pub fn take_sections(&mut self) -> Vec<Section<'a>> {320 pub fn take_sections(&mut self) -> Vec<Section<'a>> {
321 let mut to_return = vec![];321 let mut to_return = vec![];
git-config/src/parse/mod.rs+2−2
@@ -3,8 +3,8 @@ · 2 unmodified lines
3//! explicit reason to work with events instead.3//! explicit reason to work with events instead.
4//!4//!
5//! The general workflow for interacting with this is to use one of the5//! The general workflow for interacting with this is to use one of the
6//! `parse_from_*` function variants. These will return a [`State`] on success,6//! `parse_from_*` function variants. These will return a [`Events`] on success,
7//! which can be converted into an [`Event`] iterator. The [`State`] also has7//! which can be converted into an [`Event`] iterator. The [`Events`] also has
8//! additional methods for accessing leading comments or events by section.8//! additional methods for accessing leading comments or events by section.
9//!9//!
10//! [`File`]: crate::File10//! [`File`]: crate::File