| 1 | use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#; |
| 2 | use quoterust-analyzer cargo quote 1.0.38 crate/::{ToTokensrust-analyzer cargo quote 1.0.38 to_tokens/ToTokens#, TokenStreamExtrust-analyzer cargo quote 1.0.38 ext/TokenStreamExt#, quoterust-analyzer cargo quote 1.0.38 quote!}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#; |
| 4 | use synrust-analyzer cargo syn 2.0.96 crate/::Exprrust-analyzer cargo syn 2.0.96 expr/Expr#; |
| 5 | use synrust-analyzer cargo syn 2.0.96 crate/::parserust-analyzer cargo syn 2.0.96 parse/::{Errorrust-analyzer cargo syn 2.0.96 error/Error#, Parserust-analyzer cargo syn 2.0.96 parse/Parse#, ParseStreamrust-analyzer cargo syn 2.0.96 parse/ParseStream#}; |
| 6 | use synrust-analyzer cargo syn 2.0.96 crate/::punctuatedrust-analyzer cargo syn 2.0.96 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.96 punctuated/Punctuated#; |
| 7 | use synrust-analyzer cargo syn 2.0.96 crate/::spannedrust-analyzer cargo syn 2.0.96 spanned/::Spannedrust-analyzer cargo syn 2.0.96 spanned/Spanned#; |
| 8 | use synrust-analyzer cargo syn 2.0.96 crate/::{Tokenrust-analyzer cargo syn 2.0.96 token/Token!, parse_macro_inputrust-analyzer cargo syn 2.0.96 parse_macro_input/}; |
| 9 | |
| 10 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.93 crate/::{Delimiterrust-analyzer cargo proc-macro2 1.0.93 Delimiter#, Spacingrust-analyzer cargo proc-macro2 1.0.93 Spacing#, TokenStreamrust-analyzer cargo proc-macro2 1.0.93 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#, TokenTreerust-analyzer cargo proc-macro2 1.0.93 TokenTree#}; |
| 11 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.93 crate/::{Grouprust-analyzer cargo proc-macro2 1.0.93 Group#, Punctrust-analyzer cargo proc-macro2 1.0.93 Punct#}; |
| 12 | |
| 13 | /// A matrix of expressions |
| 14 | pub struct Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix# { |
| 15 | // Represent the matrix data in row-major format |
| 16 | datarust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#data.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Exprrust-analyzer cargo syn 2.0.96 expr/Expr#>, |
| 17 | nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#nrows.: usize, |
| 18 | ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#ncols.: usize, |
| 19 | } |
| 20 | |
| 21 | impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<(usize, usize)> for Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix# { |
| 22 | type Outputrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][`Index<(usize, usize)>`]Output# = Exprrust-analyzer cargo syn 2.0.96 expr/Expr#; |
| 23 | |
| 24 | fn indexrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][`Index<(usize, usize)>`]index().(&self, (row, col): (usize, usize)) -> &Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][`Index<(usize, usize)>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#Output# { |
| 25 | let linear_idx = self.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#ncols. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().row rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().col; |
| 26 | &self.datarust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#data.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().linear_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | impl Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix# { |
| 31 | pub fn nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]nrows().(&self) -> usize { |
| 32 | self.nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#nrows. |
| 33 | } |
| 34 | |
| 35 | pub fn ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]ncols().(&self) -> usize { |
| 36 | self.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#ncols. |
| 37 | } |
| 38 | |
| 39 | /// Produces a stream of tokens representing this matrix as a column-major nested array. |
| 40 | pub fn to_col_major_nested_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]to_col_major_nested_array_tokens().(&self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream# { |
| 41 | let mut result = TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream]new().(); |
| 42 | for j in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]ncols().() { |
| 43 | let mut col = TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream]new().(); |
| 44 | let col_iter = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]nrows().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| &self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().(i, j)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 45 | col.append_separatedrust-analyzer cargo quote 1.0.38 ext/impl#[TokenStream][TokenStreamExt]append_separated().(col_iter, Punctrust-analyzer cargo proc-macro2 1.0.93 Punct#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Punct]new().(',', Spacingrust-analyzer cargo proc-macro2 1.0.93 Spacing#::Alonerust-analyzer cargo proc-macro2 1.0.93 Spacing#Alone#)); |
| 46 | result.appendrust-analyzer cargo quote 1.0.38 ext/impl#[TokenStream][TokenStreamExt]append().(Grouprust-analyzer cargo proc-macro2 1.0.93 Group#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Group]new().(Delimiterrust-analyzer cargo proc-macro2 1.0.93 Delimiter#::Bracketrust-analyzer cargo proc-macro2 1.0.93 Delimiter#Bracket#, col)); |
| 47 | result.appendrust-analyzer cargo quote 1.0.38 ext/impl#[TokenStream][TokenStreamExt]append().(Punctrust-analyzer cargo proc-macro2 1.0.93 Punct#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Punct]new().(',', Spacingrust-analyzer cargo proc-macro2 1.0.93 Spacing#::Alonerust-analyzer cargo proc-macro2 1.0.93 Spacing#Alone#)); |
| 48 | } |
| 49 | TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream][`From<TokenTree>`]from().(TokenTreerust-analyzer cargo proc-macro2 1.0.93 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.93 TokenTree#Group#(Grouprust-analyzer cargo proc-macro2 1.0.93 Group#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Group]new().(Delimiterrust-analyzer cargo proc-macro2 1.0.93 Delimiter#::Bracketrust-analyzer cargo proc-macro2 1.0.93 Delimiter#Bracket#, result))) |
| 50 | } |
| 51 | |
| 52 | /// Produces a stream of tokens representing this matrix as a column-major flat array |
| 53 | /// (suitable for representing e.g. a `DMatrix`). |
| 54 | pub fn to_col_major_flat_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]to_col_major_flat_array_tokens().(&self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream# { |
| 55 | let mut data = TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream]new().(); |
| 56 | for j in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]ncols().() { |
| 57 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]nrows().() { |
| 58 | self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().(i, j)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_tokensrust-analyzer cargo syn 2.0.96 expr/impl#[Expr][ToTokens]to_tokens().(&mut data); |
| 59 | data.appendrust-analyzer cargo quote 1.0.38 ext/impl#[TokenStream][TokenStreamExt]append().(Punctrust-analyzer cargo proc-macro2 1.0.93 Punct#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Punct]new().(',', Spacingrust-analyzer cargo proc-macro2 1.0.93 Spacing#::Alonerust-analyzer cargo proc-macro2 1.0.93 Spacing#Alone#)); |
| 60 | } |
| 61 | } |
| 62 | TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream][`From<TokenTree>`]from().(TokenTreerust-analyzer cargo proc-macro2 1.0.93 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.93 TokenTree#Group#(Grouprust-analyzer cargo proc-macro2 1.0.93 Group#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Group]new().(Delimiterrust-analyzer cargo proc-macro2 1.0.93 Delimiter#::Bracketrust-analyzer cargo proc-macro2 1.0.93 Delimiter#Bracket#, data))) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | type MatrixRowSyntaxrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/MatrixRowSyntax# = Punctuatedrust-analyzer cargo syn 2.0.96 punctuated/Punctuated#<Exprrust-analyzer cargo syn 2.0.96 expr/Expr#, Tokenrust-analyzer cargo syn 2.0.96 token/Token!![,]>; |
| 67 | |
| 68 | impl Parserust-analyzer cargo syn 2.0.96 parse/Parse# for Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix# { |
| 69 | fn parserust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.96 parse/ParseStream#<'_>) -> synrust-analyzer cargo syn 2.0.96 crate/::Resultrust-analyzer cargo syn 2.0.96 error/Result#<Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][Parse]> { |
| 70 | let mut data = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 71 | let mut ncols = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 72 | let mut nrows = 0; |
| 73 | |
| 74 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 75 | let row = MatrixRowSyntaxrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/MatrixRowSyntax#::parse_separated_nonemptyrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]parse_separated_nonempty().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 76 | let row_span = row.spanrust-analyzer cargo syn 2.0.96 spanned/impl#[T][Spanned]span().(); |
| 77 | |
| 78 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ncols) = ncols { |
| 79 | if row.lenrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().ncols { |
| 80 | let error_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 81 | "Unexpected number of entries in row {}. Expected {}, found {} entries.", |
| 82 | nrows, |
| 83 | ncols, |
| 84 | row.lenrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]len().() |
| 85 | ); |
| 86 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.96 error/Error#::newrust-analyzer cargo syn 2.0.96 error/impl#[Error]new().(row_span, error_msg)); |
| 87 | } |
| 88 | } else { |
| 89 | ncols = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(row.lenrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]len().()); |
| 90 | } |
| 91 | data.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(row.into_iterrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().()); |
| 92 | nrows rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 93 | |
| 94 | // We've just read a row, so if there are more tokens, there must be a semi-colon, |
| 95 | // otherwise the input is malformed |
| 96 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 97 | input.parserust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]parse().::<Tokenrust-analyzer cargo syn 2.0.96 token/Token!![;]>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix][Parse] { |
| 102 | datarust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#data., |
| 103 | nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#nrows., |
| 104 | ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#ncols.: ncols.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0), |
| 105 | }) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | pub struct Vectorrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector# { |
| 110 | elementsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#elements.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Exprrust-analyzer cargo syn 2.0.96 expr/Expr#>, |
| 111 | } |
| 112 | |
| 113 | impl Vectorrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector# { |
| 114 | pub fn to_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]to_array_tokens().(&self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream# { |
| 115 | let mut data = TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream]new().(); |
| 116 | data.append_separatedrust-analyzer cargo quote 1.0.38 ext/impl#[TokenStream][TokenStreamExt]append_separated().(&self.elementsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#elements., Punctrust-analyzer cargo proc-macro2 1.0.93 Punct#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Punct]new().(',', Spacingrust-analyzer cargo proc-macro2 1.0.93 Spacing#::Alonerust-analyzer cargo proc-macro2 1.0.93 Spacing#Alone#)); |
| 117 | TokenStream2rust-analyzer cargo proc-macro2 1.0.93 TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[TokenStream][`From<TokenTree>`]from().(TokenTreerust-analyzer cargo proc-macro2 1.0.93 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.93 TokenTree#Group#(Grouprust-analyzer cargo proc-macro2 1.0.93 Group#::newrust-analyzer cargo proc-macro2 1.0.93 impl#[Group]new().(Delimiterrust-analyzer cargo proc-macro2 1.0.93 Delimiter#::Bracketrust-analyzer cargo proc-macro2 1.0.93 Delimiter#Bracket#, data))) |
| 118 | } |
| 119 | |
| 120 | pub fn lenrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]len().(&self) -> usize { |
| 121 | self.elementsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | impl Parserust-analyzer cargo syn 2.0.96 parse/Parse# for Vectorrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector# { |
| 126 | fn parserust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.96 parse/ParseStream#<'_>) -> synrust-analyzer cargo syn 2.0.96 crate/::Resultrust-analyzer cargo syn 2.0.96 error/Result#<Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector][Parse]> { |
| 127 | // The syntax of a vector is just the syntax of a single matrix row |
| 128 | if input.is_emptyrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 129 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector][Parse] { |
| 130 | elementsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#elements.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 131 | }) |
| 132 | } else { |
| 133 | let elements = MatrixRowSyntaxrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/MatrixRowSyntax#::parse_terminatedrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 134 | .into_iterrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().() |
| 135 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 136 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector][Parse] { elementsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#elements. }) |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | pub fn matrix_implrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/matrix_impl().(stream: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 142 | let matrix = parse_macro_inputrust-analyzer cargo syn 2.0.96 parse_macro_input/parse_macro_input!!(stream as Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#); |
| 143 | |
| 144 | let row_dim = matrix.nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]nrows().(); |
| 145 | let col_dim = matrix.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]ncols().(); |
| 146 | |
| 147 | let array_tokens = matrix.to_col_major_nested_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]to_col_major_nested_array_tokens().(); |
| 148 | |
| 149 | // TODO: Use quote_spanned instead?? |
| 150 | let output = quoterust-analyzer cargo quote 1.0.38 quote!! { |
| 151 | nalgebra::SMatrix::<_, #row_dim, #col_dim> |
| 152 | ::from_array_storage(nalgebra::ArrayStorage(#array_tokens)) |
| 153 | }; |
| 154 | |
| 155 | proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(output) |
| 156 | } |
| 157 | |
| 158 | pub fn dmatrix_implrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/dmatrix_impl().(stream: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 159 | let matrix = parse_macro_inputrust-analyzer cargo syn 2.0.96 parse_macro_input/parse_macro_input!!(stream as Matrixrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Matrix#); |
| 160 | |
| 161 | let row_dim = matrix.nrowsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]nrows().(); |
| 162 | let col_dim = matrix.ncolsrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]ncols().(); |
| 163 | |
| 164 | let array_tokens = matrix.to_col_major_flat_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Matrix]to_col_major_flat_array_tokens().(); |
| 165 | |
| 166 | // TODO: Use quote_spanned instead?? |
| 167 | let output = quoterust-analyzer cargo quote 1.0.38 quote!! { |
| 168 | nalgebra::DMatrix::<_> |
| 169 | ::from_vec_storage(nalgebra::VecStorage::new( |
| 170 | nalgebra::Dyn(#row_dim), |
| 171 | nalgebra::Dyn(#col_dim), |
| 172 | vec!#array_tokens)) |
| 173 | }; |
| 174 | |
| 175 | proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(output) |
| 176 | } |
| 177 | |
| 178 | pub fn vector_implrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/vector_impl().(stream: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 179 | let vector = parse_macro_inputrust-analyzer cargo syn 2.0.96 parse_macro_input/parse_macro_input!!(stream as Vectorrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#); |
| 180 | let len = vector.lenrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]len().(); |
| 181 | let array_tokens = vector.to_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]to_array_tokens().(); |
| 182 | let output = quoterust-analyzer cargo quote 1.0.38 quote!! { |
| 183 | nalgebra::SVector::<_, #len> |
| 184 | ::from_array_storage(nalgebra::ArrayStorage([#array_tokens])) |
| 185 | }; |
| 186 | proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(output) |
| 187 | } |
| 188 | |
| 189 | pub fn dvector_implrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/dvector_impl().(stream: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 190 | let vector = parse_macro_inputrust-analyzer cargo syn 2.0.96 parse_macro_input/parse_macro_input!!(stream as Vectorrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/Vector#); |
| 191 | let len = vector.lenrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]len().(); |
| 192 | let array_tokens = vector.to_array_tokensrust-analyzer cargo nalgebra-macros 0.3.0 matrix_vector_impl/impl#[Vector]to_array_tokens().(); |
| 193 | let output = quoterust-analyzer cargo quote 1.0.38 quote!! { |
| 194 | nalgebra::DVector::<_> |
| 195 | ::from_vec_storage(nalgebra::VecStorage::new( |
| 196 | nalgebra::Dyn(#len), |
| 197 | nalgebra::Const::<1>, |
| 198 | vec!#array_tokens)) |
| 199 | }; |
| 200 | proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(output) |
| 201 | } |