Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to wrap a struct with lifetime parameter?Β #502

@lochbrunner

Description

@lochbrunner

πŸ› Bug Reports

This is different to issue 246.

🌍 Environment

  • Your operating system and version: 4.15.0-50-generic Add PyDict::iterΒ #54-Ubuntu SMP
  • Your python version: Python 3.6.8
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: Anaconda 64bit
  • Your rust version (rustc --version): rustc 1.34.0-nightly (e1c6d0057 2019-02-22)
  • Are you using the latest pyo3 version? Have you tried using latest master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")? version: 0.7.0

πŸ’₯ Reproducing

When using a struct with lifetime as follow:

use pyo3::prelude::*;

#[pyclass]
struct MyClass<'a> {
    r: &'a u32,
}

results in the compiler error:

error[E0106]: missing lifetime specifier
--> pycore/src/trace.rs:114:8
|
114 | struct MyClass<'a> {
| ^^^^^^^ expected lifetime parameter
error: aborting due to previous error

Using dependency:

[dependencies]
pyo3 = {version = "0.7.0", features = ["extension-module"]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions