lifetime


Nested life times


I'm a bit stumped. I want following code to pass.
enum Source<'self> {
String(&'self str),
ReaderUtil(&'self ReaderUtil)
}
pub struct Matrix<'self> {
source: &'self Source
}
fn main() {
}
I started with just enum, but then because I needed to use &pointers, I had to give it a lifetime. Problem appeared when I added that enum to another struct. I know I can't give struct other lifetime than 'self but it gives me an error for lifetime, saying anonymous lifetimes aren't allowed in Source (which is same like I didn't add any lifetimes).
enum Source<'self> {
String(&'self str),
ReaderUtil(&'self ReaderUtil)
}
pub struct Matrix<'self> {
source: &'self Source<'self>
}
fn main() {
}
You declared your enum Source with a lifetime parameter, enum Source<'self>. That means you also have to declare the lifetime for Source in Matrix.

Related Links

Why can't I store a value and a reference to that value in the same struct?
Rooting managed value in Rust
Nested life times

Categories

HOME
amazon-web-services
android-espresso
knockout.js
xcode
gaming
focus
yii
paypal-ipn
plaid
header
openfoam
tweepy
kurento
specifications
cisco
clickable-image
slide
watch-os-3
game-maker
bootstrap-switch
responsivevoice
fullcalendar-scheduler
spring-jpa
distributed-computing
rest-assured
exe
mixpanel
fosuserbundle
exec-maven-plugin
bazaar
weex
dashdb
intel
websphere-portal
pubxml
oracleforms
social-networking
argv
appcode
transform
nppexec
ftp-server
spinner
gitolite
assert
1wire
expandablelistview
code-push
spongycastle
jgrapht
simple-schema
exc-bad-access
htmlspecialchars
google-news
test-data
lvalue
deviare
jsf-2.3
carmen
yii2-model
odp.net-managed
node-glob
apple-configurator
trust
ioexception
teensy
ajax4jsf
phpquery
google-maps-api-2
astropy
componentart
erlog
console.log
scala-swing
python-curses
sablecc
nhibernate-criteria
full-text-indexing
fileshare
jms-serializer
hints
dibs
proc-open
towers-of-hanoi
playorm
getproperty
image-scanner
navigationcontroller
memory-pool
haiku
snackjs
winsxs
regression-testing
git-log
jdownloader
.net-services
getimagesize
powergui
fxruby
inversion

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App