Parse the line and column number of function block. A function block is wrapped in a pair of braces, i.e. `{ ... }`
(block: &syn::Block)
| 21 | /// |
| 22 | /// A function block is wrapped in a pair of braces, i.e. `{ ... }` |
| 23 | pub(crate) fn parse_body_loc_start(block: &syn::Block) -> LineColumn { |
| 24 | // Given a function like... the `loc.column` will be at |
| 25 | // - `fn func<T>(i: T) -> T where T: Into<u64> { ` |
| 26 | // ^ |
| 27 | // - `fn func<T>(i: T) -> T where T: Into<u64>{ ` |
| 28 | // ^ |
| 29 | // - `fn func() { ` |
| 30 | // ^ |
| 31 | // - `fn func(){ ` |
| 32 | // ^ |
| 33 | // However, we want the `loc.column` to be one character after `{`, i.e. |
| 34 | // - `fn func<T>(i: T) -> T where T: Into<u64> { ` |
| 35 | // ^ |
| 36 | // - `fn func<T>(i: T) -> T where T: Into<u64>{ ` |
| 37 | // ^ |
| 38 | // - `fn func() { ` |
| 39 | // ^ |
| 40 | // - `fn func(){ ` |
| 41 | // ^ |
| 42 | let mut loc: LineColumn = block.span().start().into_loc(); |
| 43 | // Hence, `loc.column + 2` |
| 44 | if let Some(col) = loc.column.as_mut() { |
| 45 | *col += 2; |
| 46 | } |
| 47 | loc |
| 48 | } |
| 49 | |
| 50 | /// Parse the line and column number of function block. |
| 51 | /// |
no test coverage detected