• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davidcole1340 / ext-php-rs / 17032997319

18 Aug 2025 06:35AM UTC coverage: 26.78% (-1.0%) from 27.748%
17032997319

Pull #533

github

web-flow
Merge c0dcacdd2 into 95bebee0d
Pull Request #533: Feat/interface impl

9 of 183 new or added lines in 9 files covered. (4.92%)

3 existing lines in 2 files now uncovered.

1162 of 4339 relevant lines covered (26.78%)

7.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/macros/src/function.rs
1
use std::collections::HashMap;
2

3
use darling::{FromAttributes, ToTokens};
4
use proc_macro2::{Ident, Span, TokenStream};
5
use quote::{format_ident, quote};
6
use syn::spanned::Spanned as _;
7
use syn::{Expr, FnArg, GenericArgument, ItemFn, PatType, PathArguments, Type, TypePath};
8

9
use crate::helpers::get_docs;
10
use crate::parsing::{PhpRename, RenameRule, Visibility};
11
use crate::prelude::*;
12
use crate::syn_ext::DropLifetimes;
13

14
pub fn wrap(input: &syn::Path) -> Result<TokenStream> {
×
15
    let Some(func_name) = input.get_ident() else {
×
16
        bail!(input => "Pass a PHP function name into `wrap_function!()`.");
×
17
    };
18
    let builder_func = format_ident!("_internal_{func_name}");
19

20
    Ok(quote! {{
21
        (<#builder_func as ::ext_php_rs::internal::function::PhpFunction>::FUNCTION_ENTRY)()
22
    }})
23
}
24

25
#[derive(FromAttributes, Default, Debug)]
26
#[darling(default, attributes(php), forward_attrs(doc))]
27
struct PhpFunctionAttribute {
28
    #[darling(flatten)]
29
    rename: PhpRename,
30
    defaults: HashMap<Ident, Expr>,
31
    optional: Option<Ident>,
32
    vis: Option<Visibility>,
33
    attrs: Vec<syn::Attribute>,
34
}
35

36
pub fn parser(mut input: ItemFn) -> Result<TokenStream> {
×
37
    let php_attr = PhpFunctionAttribute::from_attributes(&input.attrs)?;
×
38
    input.attrs.retain(|attr| !attr.path().is_ident("php"));
×
39

40
    let args = Args::parse_from_fnargs(input.sig.inputs.iter(), php_attr.defaults)?;
×
41
    if let Some(ReceiverArg { span, .. }) = args.receiver {
×
42
        bail!(span => "Receiver arguments are invalid on PHP functions. See `#[php_impl]`.");
43
    }
44

45
    let docs = get_docs(&php_attr.attrs)?;
×
46

47
    let func = Function::new(
48
        &input.sig,
49
        php_attr
50
            .rename
51
            .rename(input.sig.ident.to_string(), RenameRule::Snake),
52
        args,
53
        php_attr.optional,
54
        docs,
55
    );
56
    let function_impl = func.php_function_impl();
57

58
    Ok(quote! {
59
        #input
60
        #function_impl
61
    })
62
}
63

64
#[derive(Debug)]
65
pub struct Function<'a> {
66
    /// Identifier of the Rust function associated with the function.
67
    pub ident: &'a Ident,
68
    /// Name of the function in PHP.
69
    pub name: String,
70
    /// Function arguments.
71
    pub args: Args<'a>,
72
    /// Function outputs.
73
    pub output: Option<&'a Type>,
74
    /// The first optional argument of the function.
75
    pub optional: Option<Ident>,
76
    /// Doc comments for the function.
77
    pub docs: Vec<String>,
78
}
79

80
#[derive(Debug)]
81
pub enum CallType<'a> {
82
    Function,
83
    Method {
84
        class: &'a syn::Path,
85
        receiver: MethodReceiver,
86
    },
87
}
88

89
/// Type of receiver on the method.
90
#[derive(Debug)]
91
pub enum MethodReceiver {
92
    /// Static method - has no receiver.
93
    Static,
94
    /// Class method, takes `&self` or `&mut self`.
95
    Class,
96
    /// Class method, takes `&mut ZendClassObject<Self>`.
97
    ZendClassObject,
98
}
99

100
impl<'a> Function<'a> {
101
    /// Parse a function.
102
    ///
103
    /// # Parameters
104
    ///
105
    /// * `sig` - Function signature.
106
    /// * `name` - Function name in PHP land.
107
    /// * `args` - Function arguments.
108
    /// * `optional` - The ident of the first optional argument.
109
    pub fn new(
×
110
        sig: &'a syn::Signature,
111
        name: String,
112
        args: Args<'a>,
113
        optional: Option<Ident>,
114
        docs: Vec<String>,
115
    ) -> Self {
116
        Self {
117
            ident: &sig.ident,
×
118
            name,
119
            args,
120
            output: match &sig.output {
×
121
                syn::ReturnType::Default => None,
122
                syn::ReturnType::Type(_, ty) => Some(&**ty),
123
            },
124
            optional,
125
            docs,
126
        }
127
    }
128

129
    /// Generates an internal identifier for the function.
130
    pub fn internal_ident(&self) -> Ident {
×
131
        format_ident!("_internal_{}", &self.ident)
×
132
    }
133

NEW
134
    pub fn abstract_function_builder(&self) -> TokenStream {
×
NEW
135
        let name = &self.name;
×
NEW
136
        let (required, not_required) = self.args.split_args(self.optional.as_ref());
×
137

138
        // `entry` impl
NEW
139
        let required_args = required
×
140
            .iter()
NEW
141
            .map(TypedArg::arg_builder)
×
142
            .collect::<Vec<_>>();
NEW
143
        let not_required_args = not_required
×
144
            .iter()
NEW
145
            .map(TypedArg::arg_builder)
×
146
            .collect::<Vec<_>>();
147

NEW
148
        let returns = self.build_returns();
×
NEW
149
        let docs = if self.docs.is_empty() {
×
NEW
150
            quote! {}
×
151
        } else {
NEW
152
            let docs = &self.docs;
×
NEW
153
            quote! {
×
NEW
154
                .docs(&[#(#docs),*])
×
155
            }
156
        };
157

NEW
158
        quote! {
×
NEW
159
            ::ext_php_rs::builders::FunctionBuilder::new_abstract(#name)
×
NEW
160
            #(.arg(#required_args))*
×
NEW
161
            .not_required()
×
NEW
162
            #(.arg(#not_required_args))*
×
NEW
163
            #returns
×
NEW
164
            #docs
×
165
        }
166
    }
167

168
    /// Generates the function builder for the function.
169
    pub fn function_builder(&self, call_type: CallType) -> TokenStream {
×
170
        let name = &self.name;
×
171
        let (required, not_required) = self.args.split_args(self.optional.as_ref());
×
172

173
        // `handler` impl
174
        let arg_declarations = self
×
175
            .args
×
176
            .typed
×
177
            .iter()
178
            .map(TypedArg::arg_declaration)
×
179
            .collect::<Vec<_>>();
180

181
        // `entry` impl
182
        let required_args = required
×
183
            .iter()
184
            .map(TypedArg::arg_builder)
×
185
            .collect::<Vec<_>>();
186
        let not_required_args = not_required
×
187
            .iter()
188
            .map(TypedArg::arg_builder)
×
189
            .collect::<Vec<_>>();
190

191
        let returns = self.build_returns();
×
192
        let result = self.build_result(call_type, required, not_required);
×
193
        let docs = if self.docs.is_empty() {
×
194
            quote! {}
×
195
        } else {
196
            let docs = &self.docs;
×
197
            quote! {
×
198
                .docs(&[#(#docs),*])
×
199
            }
200
        };
201

202
        quote! {
×
203
            ::ext_php_rs::builders::FunctionBuilder::new(#name, {
×
204
                ::ext_php_rs::zend_fastcall! {
×
205
                    extern fn handler(
×
206
                        ex: &mut ::ext_php_rs::zend::ExecuteData,
×
207
                        retval: &mut ::ext_php_rs::types::Zval,
×
208
                    ) {
209
                        use ::ext_php_rs::convert::IntoZval;
×
210

211
                        #(#arg_declarations)*
×
212
                        let result = {
×
213
                            #result
×
214
                        };
215

216
                        if let Err(e) = result.set_zval(retval, false) {
×
217
                            let e: ::ext_php_rs::exception::PhpException = e.into();
×
218
                            e.throw().expect("Failed to throw PHP exception.");
×
219
                        }
220
                    }
221
                }
222
                handler
×
223
            })
224
            #(.arg(#required_args))*
×
225
            .not_required()
×
226
            #(.arg(#not_required_args))*
×
227
            #returns
×
228
            #docs
×
229
        }
230
    }
231

232
    fn build_returns(&self) -> Option<TokenStream> {
×
233
        self.output.cloned().map(|mut output| {
×
234
            output.drop_lifetimes();
×
235
            quote! {
×
236
                .returns(
×
237
                    <#output as ::ext_php_rs::convert::IntoZval>::TYPE,
×
238
                    false,
×
239
                    <#output as ::ext_php_rs::convert::IntoZval>::NULLABLE,
×
240
                )
241
            }
242
        })
243
    }
244

245
    fn build_result(
×
246
        &self,
247
        call_type: CallType,
248
        required: &[TypedArg<'_>],
249
        not_required: &[TypedArg<'_>],
250
    ) -> TokenStream {
251
        let ident = self.ident;
×
252
        let required_arg_names: Vec<_> = required.iter().map(|arg| arg.name).collect();
×
253
        let not_required_arg_names: Vec<_> = not_required.iter().map(|arg| arg.name).collect();
×
254

255
        let arg_accessors = self.args.typed.iter().map(|arg| {
×
256
            arg.accessor(|e| {
×
257
                quote! {
×
258
                    #e.throw().expect("Failed to throw PHP exception.");
×
259
                    return;
×
260
                }
261
            })
262
        });
263

264
        match call_type {
×
265
            CallType::Function => quote! {
×
266
                let parse = ex.parser()
×
267
                    #(.arg(&mut #required_arg_names))*
×
268
                    .not_required()
×
269
                    #(.arg(&mut #not_required_arg_names))*
×
270
                    .parse();
×
271
                if parse.is_err() {
×
272
                    return;
×
273
                }
274

275
                #ident(#({#arg_accessors}),*)
×
276
            },
277
            CallType::Method { class, receiver } => {
×
278
                let this = match receiver {
×
279
                    MethodReceiver::Static => quote! {
×
280
                        let parse = ex.parser();
×
281
                    },
282
                    MethodReceiver::ZendClassObject | MethodReceiver::Class => quote! {
×
283
                        let (parse, this) = ex.parser_method::<#class>();
×
284
                        let this = match this {
×
285
                            Some(this) => this,
×
286
                            None => {
×
287
                                ::ext_php_rs::exception::PhpException::default("Failed to retrieve reference to `$this`".into())
×
288
                                    .throw()
×
289
                                    .unwrap();
×
290
                                return;
×
291
                            }
292
                        };
293
                    },
294
                };
295
                let call = match receiver {
×
296
                    MethodReceiver::Static => {
×
297
                        quote! { #class::#ident(#({#arg_accessors}),*) }
×
298
                    }
299
                    MethodReceiver::Class => quote! { this.#ident(#({#arg_accessors}),*) },
×
300
                    MethodReceiver::ZendClassObject => {
×
301
                        quote! { #class::#ident(this, #({#arg_accessors}),*) }
×
302
                    }
303
                };
304
                quote! {
×
305
                    #this
×
306
                    let parse_result = parse
×
307
                        #(.arg(&mut #required_arg_names))*
×
308
                        .not_required()
×
309
                        #(.arg(&mut #not_required_arg_names))*
×
310
                        .parse();
×
311
                    if parse_result.is_err() {
×
312
                        return;
×
313
                    }
314

315
                    #call
×
316
                }
317
            }
318
        }
319
    }
320

321
    /// Generates a struct and impl for the `PhpFunction` trait.
322
    pub fn php_function_impl(&self) -> TokenStream {
×
323
        let internal_ident = self.internal_ident();
×
324
        let builder = self.function_builder(CallType::Function);
×
325

326
        quote! {
×
327
            #[doc(hidden)]
×
328
            #[allow(non_camel_case_types)]
×
329
            struct #internal_ident;
×
330

331
            impl ::ext_php_rs::internal::function::PhpFunction for #internal_ident {
×
332
                const FUNCTION_ENTRY: fn() -> ::ext_php_rs::builders::FunctionBuilder<'static> = {
×
333
                    fn entry() -> ::ext_php_rs::builders::FunctionBuilder<'static>
×
334
                    {
335
                        #builder
×
336
                    }
337
                    entry
×
338
                };
339
            }
340
        }
341
    }
342

343
    /// Returns a constructor metadata object for this function. This doesn't
344
    /// check if the function is a constructor, however.
345
    pub fn constructor_meta(
×
346
        &self,
347
        class: &syn::Path,
348
        visibility: Option<&Visibility>,
349
    ) -> TokenStream {
350
        let ident = self.ident;
×
351
        let (required, not_required) = self.args.split_args(self.optional.as_ref());
×
352
        let required_args = required
×
353
            .iter()
354
            .map(TypedArg::arg_builder)
×
355
            .collect::<Vec<_>>();
356
        let not_required_args = not_required
×
357
            .iter()
358
            .map(TypedArg::arg_builder)
×
359
            .collect::<Vec<_>>();
360

361
        let required_arg_names: Vec<_> = required.iter().map(|arg| arg.name).collect();
×
362
        let not_required_arg_names: Vec<_> = not_required.iter().map(|arg| arg.name).collect();
×
363
        let arg_declarations = self
×
364
            .args
×
365
            .typed
×
366
            .iter()
367
            .map(TypedArg::arg_declaration)
×
368
            .collect::<Vec<_>>();
369
        let arg_accessors = self.args.typed.iter().map(|arg| {
×
370
            arg.accessor(
×
371
                |e| quote! { return ::ext_php_rs::class::ConstructorResult::Exception(#e); },
×
372
            )
373
        });
374
        let variadic = self.args.typed.iter().any(|arg| arg.variadic).then(|| {
×
375
            quote! {
×
376
                .variadic()
×
377
            }
378
        });
379
        let docs = &self.docs;
×
380
        let flags = visibility.option_tokens();
×
381

382
        quote! {
×
383
            ::ext_php_rs::class::ConstructorMeta {
×
384
                constructor: {
×
385
                    fn inner(ex: &mut ::ext_php_rs::zend::ExecuteData) -> ::ext_php_rs::class::ConstructorResult<#class> {
×
386
                        #(#arg_declarations)*
×
387
                        let parse = ex.parser()
×
388
                            #(.arg(&mut #required_arg_names))*
×
389
                            .not_required()
×
390
                            #(.arg(&mut #not_required_arg_names))*
×
391
                            #variadic
×
392
                            .parse();
×
393
                        if parse.is_err() {
×
394
                            return ::ext_php_rs::class::ConstructorResult::ArgError;
×
395
                        }
396
                        #class::#ident(#({#arg_accessors}),*).into()
×
397
                    }
398
                    inner
×
399
                },
400
                build_fn: {
×
401
                    fn inner(func: ::ext_php_rs::builders::FunctionBuilder) -> ::ext_php_rs::builders::FunctionBuilder {
×
402
                        func
×
403
                            .docs(&[#(#docs),*])
×
404
                            #(.arg(#required_args))*
×
405
                            .not_required()
×
406
                            #(.arg(#not_required_args))*
×
407
                            #variadic
×
408
                    }
409
                    inner
×
410
                },
411
                flags: #flags
×
412
            }
413
        }
414
    }
415
}
416

417
#[derive(Debug)]
418
pub struct ReceiverArg {
419
    pub _mutable: bool,
420
    pub span: Span,
421
}
422

423
#[derive(Debug)]
424
pub struct TypedArg<'a> {
425
    pub name: &'a Ident,
426
    pub ty: Type,
427
    pub nullable: bool,
428
    pub default: Option<Expr>,
429
    pub as_ref: bool,
430
    pub variadic: bool,
431
}
432

433
#[derive(Debug)]
434
pub struct Args<'a> {
435
    pub receiver: Option<ReceiverArg>,
436
    pub typed: Vec<TypedArg<'a>>,
437
}
438

439
impl<'a> Args<'a> {
440
    pub fn parse_from_fnargs(
×
441
        args: impl Iterator<Item = &'a FnArg>,
442
        mut defaults: HashMap<Ident, Expr>,
443
    ) -> Result<Self> {
444
        let mut result = Self {
445
            receiver: None,
446
            typed: vec![],
×
447
        };
448
        for arg in args {
×
449
            match arg {
×
450
                FnArg::Receiver(receiver) => {
×
451
                    if receiver.reference.is_none() {
×
452
                        bail!(receiver => "PHP objects are heap-allocated and cannot be passed by value. Try using `&self` or `&mut self`.");
×
453
                    } else if result.receiver.is_some() {
×
454
                        bail!(receiver => "Too many receivers specified.")
×
455
                    }
456
                    result.receiver.replace(ReceiverArg {
×
457
                        _mutable: receiver.mutability.is_some(),
×
458
                        span: receiver.span(),
×
459
                    });
460
                }
461
                FnArg::Typed(PatType { pat, ty, .. }) => {
×
462
                    let syn::Pat::Ident(syn::PatIdent { ident, .. }) = &**pat else {
×
463
                        bail!(pat => "Unsupported argument.");
×
464
                    };
465

466
                    // If the variable is `&[&Zval]` treat it as the variadic argument.
467
                    let default = defaults.remove(ident);
×
468
                    let nullable = type_is_nullable(ty.as_ref(), default.is_some())?;
×
469
                    let (variadic, as_ref, ty) = Self::parse_typed(ty);
×
470
                    result.typed.push(TypedArg {
×
471
                        name: ident,
×
472
                        ty,
×
473
                        nullable,
×
474
                        default,
×
475
                        as_ref,
×
476
                        variadic,
×
477
                    });
478
                }
479
            }
480
        }
481
        Ok(result)
×
482
    }
483

484
    fn parse_typed(ty: &Type) -> (bool, bool, Type) {
×
485
        match ty {
×
486
            Type::Reference(ref_) => {
×
487
                let as_ref = ref_.mutability.is_some();
×
488
                match ref_.elem.as_ref() {
×
489
                    Type::Slice(slice) => (
×
490
                        // TODO: Allow specifying the variadic type.
491
                        slice.elem.to_token_stream().to_string() == "& Zval",
×
492
                        as_ref,
×
493
                        ty.clone(),
×
494
                    ),
495
                    _ => (false, as_ref, ty.clone()),
×
496
                }
497
            }
498
            Type::Path(TypePath { path, .. }) => {
×
499
                let mut as_ref = false;
×
500

501
                // For for types that are `Option<&mut T>` to turn them into
502
                // `Option<&T>`, marking the Arg as as "passed by reference".
503
                let ty = path
×
504
                    .segments
×
505
                    .last()
506
                    .filter(|seg| seg.ident == "Option")
×
507
                    .and_then(|seg| {
×
508
                        if let PathArguments::AngleBracketed(args) = &seg.arguments {
×
509
                            args.args
×
510
                                .iter()
×
511
                                .find(|arg| matches!(arg, GenericArgument::Type(_)))
×
512
                                .and_then(|ga| match ga {
×
513
                                    GenericArgument::Type(ty) => Some(match ty {
×
514
                                        Type::Reference(r) => {
×
515
                                            let mut new_ref = r.clone();
×
516
                                            new_ref.mutability = None;
×
517
                                            as_ref = true;
×
518
                                            Type::Reference(new_ref)
×
519
                                        }
520
                                        _ => ty.clone(),
×
521
                                    }),
522
                                    _ => None,
×
523
                                })
524
                        } else {
525
                            None
×
526
                        }
527
                    })
528
                    .unwrap_or_else(|| ty.clone());
×
529
                (false, as_ref, ty.clone())
×
530
            }
531
            _ => (false, false, ty.clone()),
×
532
        }
533
    }
534

535
    /// Splits the typed arguments into two slices:
536
    ///
537
    /// 1. Required arguments.
538
    /// 2. Non-required arguments.
539
    ///
540
    /// # Parameters
541
    ///
542
    /// * `optional` - The first optional argument. If [`None`], the optional
543
    ///   arguments will be from the first nullable argument after the last
544
    ///   non-nullable argument to the end of the arguments.
545
    pub fn split_args(&self, optional: Option<&Ident>) -> (&[TypedArg<'a>], &[TypedArg<'a>]) {
×
546
        let mut mid = None;
×
547
        for (i, arg) in self.typed.iter().enumerate() {
×
548
            if let Some(optional) = optional {
×
549
                if optional == arg.name {
×
550
                    mid.replace(i);
×
551
                }
552
            } else if mid.is_none() && arg.nullable {
×
553
                mid.replace(i);
×
554
            } else if !arg.nullable {
×
555
                mid.take();
×
556
            }
557
        }
558
        match mid {
×
559
            Some(mid) => (&self.typed[..mid], &self.typed[mid..]),
×
560
            None => (&self.typed[..], &self.typed[0..0]),
×
561
        }
562
    }
563
}
564

565
impl TypedArg<'_> {
566
    /// Returns a 'clean type' with the lifetimes removed. This allows the type
567
    /// to be used outside of the original function context.
568
    fn clean_ty(&self) -> Type {
×
569
        let mut ty = self.ty.clone();
×
570
        ty.drop_lifetimes();
×
571

572
        // Variadic arguments are passed as slices, so we need to extract the
573
        // inner type.
574
        if self.variadic {
×
575
            let Type::Reference(reference) = &ty else {
×
576
                return ty;
×
577
            };
578

579
            if let Type::Slice(inner) = &*reference.elem {
×
580
                return *inner.elem.clone();
581
            }
582
        }
583

584
        ty
×
585
    }
586

587
    /// Returns a token stream containing an argument declaration, where the
588
    /// name of the variable holding the arg is the name of the argument.
589
    fn arg_declaration(&self) -> TokenStream {
×
590
        let name = self.name;
×
591
        let val = self.arg_builder();
×
592
        quote! {
×
593
            let mut #name = #val;
594
        }
595
    }
596

597
    /// Returns a token stream containing the `Arg` definition to be passed to
598
    /// `ext-php-rs`.
599
    fn arg_builder(&self) -> TokenStream {
×
600
        let name = self.name.to_string();
×
601
        let ty = self.clean_ty();
×
602
        let null = if self.nullable {
×
603
            Some(quote! { .allow_null() })
×
604
        } else {
605
            None
×
606
        };
607
        let default = self.default.as_ref().map(|val| {
×
608
            let val = val.to_token_stream().to_string();
×
609
            quote! {
×
610
                .default(#val)
611
            }
612
        });
613
        let as_ref = if self.as_ref {
×
614
            Some(quote! { .as_ref() })
×
615
        } else {
616
            None
×
617
        };
618
        let variadic = self.variadic.then(|| quote! { .is_variadic() });
×
619
        quote! {
×
620
            ::ext_php_rs::args::Arg::new(#name, <#ty as ::ext_php_rs::convert::FromZvalMut>::TYPE)
621
                #null
622
                #default
623
                #as_ref
624
                #variadic
625
        }
626
    }
627

628
    /// Get the accessor used to access the value of the argument.
629
    fn accessor(&self, bail_fn: impl Fn(TokenStream) -> TokenStream) -> TokenStream {
×
630
        let name = self.name;
×
631
        if let Some(default) = &self.default {
×
632
            quote! {
×
633
                #name.val().unwrap_or(#default.into())
×
634
            }
635
        } else if self.variadic {
×
636
            quote! {
×
637
                &#name.variadic_vals()
×
638
            }
639
        } else if self.nullable {
×
640
            // Originally I thought we could just use the below case for `null` options, as
641
            // `val()` will return `Option<Option<T>>`, however, this isn't the case when
642
            // the argument isn't given, as the underlying zval is null.
643
            quote! {
×
644
                #name.val()
×
645
            }
646
        } else {
647
            let bail = bail_fn(quote! {
×
648
                ::ext_php_rs::exception::PhpException::default(
×
649
                    concat!("Invalid value given for argument `", stringify!(#name), "`.").into()
×
650
                )
651
            });
652
            quote! {
×
653
                match #name.val() {
×
654
                    Some(val) => val,
×
655
                    None => {
×
656
                        #bail;
×
657
                    }
658
                }
659
            }
660
        }
661
    }
662
}
663

664
/// Returns true of the given type is nullable in PHP.
665
// TODO(david): Eventually move to compile-time constants for this (similar to
666
// FromZval::NULLABLE).
667
pub fn type_is_nullable(ty: &Type, has_default: bool) -> Result<bool> {
×
668
    Ok(match ty {
×
669
        syn::Type::Path(path) => {
×
670
            has_default
671
                || path
×
672
                    .path
×
673
                    .segments
×
674
                    .iter()
×
675
                    .next_back()
676
                    .is_some_and(|seg| seg.ident == "Option")
×
677
        }
678
        syn::Type::Reference(_) => false, /* Reference cannot be nullable unless */
×
679
        // wrapped in `Option` (in that case it'd be a Path).
680
        _ => bail!(ty => "Unsupported argument type."),
×
681
    })
682
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc