cxx_build/syntax/signature.rs
1use crate::syntax::{FnKind, Receiver, Signature};
2use proc_macro2::Ident;
3
4impl Signature {
5 pub fn receiver(&self) -> Option<&Receiver> {
6 match &self.kind {
7 FnKind::Method(receiver) => Some(receiver),
8 FnKind::Assoc(_) | FnKind::Free => None,
9 }
10 }
11
12 pub fn receiver_mut(&mut self) -> Option<&mut Receiver> {
13 match &mut self.kind {
14 FnKind::Method(receiver) => Some(receiver),
15 FnKind::Assoc(_) | FnKind::Free => None,
16 }
17 }
18
19 pub fn self_type(&self) -> Option<&Ident> {
20 match &self.kind {
21 FnKind::Method(receiver) => Some(&receiver.ty.rust),
22 FnKind::Assoc(self_type) => Some(self_type),
23 FnKind::Free => None,
24 }
25 }
26}