Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not create pointer like types in Rust (without excessive gunk) #5771

Closed
mstewartgallus opened this issue Apr 7, 2013 · 4 comments
Closed
Assignees
Labels
A-lifetimes Area: Lifetimes / regions C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@mstewartgallus
Copy link
Contributor

I wanted to wrap the OpenGL API to create a safer interface. Like many other APIs the OpenGL API gives away integer tokens representing created objects. For example, the call glCreateProgram creates a GLuint token representing a shader program object. These tokens in the OpenGL API (and other similar APIs) are basically the same idea as pointer types. Because these tokens behave similarly to pointers I would like to wrap them in a type which has similar behaviours. For example, the glGetAttribLocation call gets a token representing an attribute, or buffer to fill with data of a shader program. I would like to wrap the token returned by glGetAttribLocation in a structure which has the same lifetime as the program token returned by glCreateProgram, but to do this I have to use an unneeded amount of pointers (to get proper lifetime guarantees.) Basically, I would like my wrapped glGetAttribLocation call to be like:

 impl GLContext {
  fn get_attrib_location <'r> (
     &self,
     program: Program <'r>,
     name: ~str
  ) -> Option <AttributeLocation <'r>> { /* Definition Omitted */ }

Instead of:

 impl GLContext {
  fn get_attrib_location <'r> (
     &self,
     program: &'r Program,
     name: ~str
  ) -> Option <AttributeLocation <'r>> { /* Definition Omitted */ }
@catamorphism
Copy link
Contributor

far-future

@emberian
Copy link
Member

emberian commented Aug 5, 2013

Visiting for traige; nothing to add.

@thestinger
Copy link
Contributor

Closing as duplicate of #5922

@thestinger
Copy link
Contributor

It seems we have at least of few reports of this, going to clean it up a bit.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 14, 2020
…atthiaskrgr

single_match_else - single expr/stmt else block corner case

One approach to fix rust-lang#3489.
See discussion in the issue.

changelog: single_match_else - single expr/stmt else block corner case fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants