MCPcopy Create free account
hub / github.com/cryptape/rust-numext / output

Method output

constructor/src/fixed_uint/core/constructor.rs:224–260  ·  view source on GitHub ↗
(&self, ucs: &[Self])

Source from the content-addressed store, hash-verified

222 }
223
224 pub fn output(&self, ucs: &[Self]) -> (TokenStream, TokenStream) {
225 self.defstruct();
226 self.deferror();
227 self.defutils();
228 self.deftraits();
229 let name = &self.ts.name;
230 let feature = &self.ts.feature;
231 let mod_name = &self.ts.mod_name;
232 let uint_common = TokenStream::from_iter(self.uint_common.take());
233 let defuns = TokenStream::from_iter(self.defuns.take());
234 let implts = TokenStream::from_iter(self.implts.take());
235 let one_uint = quote!(
236 #uint_common
237
238 #[cfg(feature = #feature)]
239 #[doc(hide)]
240 mod #mod_name {
241 use crate::*;
242 impl #name {
243 #defuns
244 }
245 #implts
246 }
247 );
248 let public = if ucs.is_empty() {
249 // define common part for all fixed uints
250 TokenStream::from_iter(self.common.take())
251 } else {
252 // define convert methods (From, Into) between two fixed uints
253 ucs.iter().fold(quote!(), |all, ref uc| {
254 let convert_into = self.convert_into(uc);
255 let convert_from = uc.convert_into(self);
256 quote!(#all #convert_into #convert_from)
257 })
258 };
259 (one_uint, public)
260 }
261
262 pub fn clear(&self) {
263 let _ = self.uint_common.take();

Callers 1

construct_allMethod · 0.45

Calls 5

defstructMethod · 0.45
deferrorMethod · 0.45
defutilsMethod · 0.45
deftraitsMethod · 0.45
convert_intoMethod · 0.45

Tested by

no test coverage detected