Skip to content

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

Closed
@mstewartgallus

Description

@mstewartgallus
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 */ }

Activity

catamorphism

catamorphism commented on May 24, 2013

@catamorphism
Contributor

far-future

emberian

emberian commented on Aug 5, 2013

@emberian
Member

Visiting for traige; nothing to add.

thestinger

thestinger commented on Sep 7, 2013

@thestinger
Contributor

Closing as duplicate of #5922

thestinger

thestinger commented on Sep 7, 2013

@thestinger
Contributor

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

added a commit that references this issue on Jul 14, 2020

Auto merge of rust-lang#5771 - montrivo:bugfix/single-match-else, r=m…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @nikomatsakis@catamorphism@emberian@thestinger@mstewartgallus

      Issue actions

        Can not create pointer like types in Rust (without excessive gunk) · Issue #5771 · rust-lang/rust