Skip to content
Myr

this.rs

This file

Path

serde_derive/src/this.rs

32 lines · 1007 bytes · Rust

Last changed by

Not known.

History of this file

Take it

1use crate::internals::ast::Container;2use syn::{Path, PathArguments, Token};34pub fn this_type(cont: &Container) -> Path {5    if let Some(remote) = cont.attrs.remote() {6        let mut this = remote.clone();7        for segment in &mut this.segments {8            if let PathArguments::AngleBracketed(arguments) = &mut segment.arguments {9                arguments.colon2_token = None;10            }11        }12        this13    } else {14        Path::from(cont.ident.clone())15    }16}1718pub fn this_value(cont: &Container) -> Path {19    if let Some(remote) = cont.attrs.remote() {20        let mut this = remote.clone();21        for segment in &mut this.segments {22            if let PathArguments::AngleBracketed(arguments) = &mut segment.arguments {23                if arguments.colon2_token.is_none() {24                    arguments.colon2_token = Some(Token![::](arguments.lt_token.span));25                }26            }27        }28        this29    } else {30        Path::from(cont.ident.clone())31    }32}