Giter VIP home page Giter VIP logo

rust's People

Contributors

alexcrichton avatar bblum avatar bluss avatar bors avatar brendanzab avatar brson avatar catamorphism avatar cixtor avatar eddyb avatar eholk avatar emberian avatar erickt avatar graydon avatar huonw avatar jbclements avatar killerswan avatar lilyball avatar lkuper avatar luqmana avatar marijnh avatar michaelwoerister avatar msullivan avatar nikomatsakis avatar olsonjeffery avatar paulstansifer avatar pcwalton avatar pnkfelix avatar sfackler avatar steveklabnik avatar thestinger avatar

Watchers

 avatar

rust's Issues

Inconsistent feel to Vector, ImmutableVector and MutableVector

Currently it feels like there is a slight inconsistency in std::slice between the following traits

  • Vector - an object can provide a slice view into itself (as_slice).
  • ImmutableVector - an object provides methods for slicing and dicing by integral index.
  • MutableVector - an object provides both a slice view into itself (as_mut_slice) and methods for directly manipulating that object.

In practice, this means I can write a generic function fn needs_slice<T: Vector>(x: &T) that manipulate x only via its as_slice representation. Then I can easily declare that some new funky object can masquerade as a slice by simply implementing a single method.

  • for example, if Option<T> implemented Vector (rather than its own as_slice) then I could pass one to needs_slice

In contrast, I can also write a function fn needs_mut_slice<T: MutableVector>(x: &T) that manipulates x only via its slice representation as_mut_slice. But I can't declare that some new funky object can masquerade as a mutable slice without adding a bunch of other methods that I don't actually want exposed on that object ... all I really want to do is implement just as_mut_slice.

So it feels like there should be four traits:

  • SliceAccessor - an object can provide a slice view into itself (as_slice)
  • MutableSliceAccessor - an object can provide a mutable slice view into itself (as_mut_slice)
  • ImmutableVector - an object provides a large number of methods for slicing and dicing itself.
  • MutableVector - an object provides methods for directly manipulating the object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.