# Struct proc_macro::Op[−][src]

    pub struct Op { /* fields omitted */ }

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

An `Op` is an operator like `+` or `-`, and only represents one character.

Operators like `+=` are represented as two instance of `Op` with different forms of `Spacing` returned.

## Methods

###

`impl Op`

[src]

####

`pub fn new(op: char, spacing: Spacing) -> Op`

[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Creates a new `Op` from the given character and spacing.

The returned `Op` will have the default span of `Span::call_site()` which can be further configured with the `set_span` method below.

####

`pub fn op(&self) -> char`

[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Returns the character this operation represents, for example `'+'`

####

`pub fn spacing(&self) -> Spacing`

[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Returns the spacing of this operator, indicating whether it's a joint operator with more operators coming next in the token stream or an `Alone` meaning that the operator has ended.

####

`pub fn span(&self) -> Span`

[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Returns the span for this operator character

####

`pub fn set_span(&mut self, span: Span)`

[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Configure the span for this operator's character

## Trait Implementations

###

`impl From<Op> for TokenTree`

[src]

####

`fn from(g: Op) -> TokenTree`

[src]

Performs the conversion.

###

`impl Copy for Op`

[src]

###

`impl Clone for Op`

[src]

####

`fn clone(&self) -> Op`

[src]

Returns a copy of the value. Read more

####

`fn clone_from(&mut self, source: &Self)`

1.0.0
[src]

Performs copy-assignment from `source`. Read more

###

`impl Debug for Op`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result`

[src]

Formats the value using the given formatter. Read more

###

`impl !Send for Op`

[src]

###

`impl !Sync for Op`

[src]

###

`impl Display for Op`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result`

[src]

Formats the value using the given formatter. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)