Skip to main content

Questions tagged [trait]

A scala trait is roughly the equivalent of an interface in Java. It can be extended as if it were a class, and can contain concrete and abstract methods as well as variables.

Filter by
Sorted by
Tagged with
2 votes
0 answers
62 views

Trait to extend std::io::Read and std::io::Write

While implementing a proprietary networking protocol, I found myself instantiating buffers of different sizes all the time, reading from a std::io::Reader into it ...
Richard Neumann's user avatar
4 votes
1 answer
138 views

Implement Seek on /dev/stdin file descriptor in Rust

Problem: In order to be able to use the arrow crate's infer_file_schema function with input piped to ...
Cornelius Roemer's user avatar
0 votes
1 answer
105 views

Extend iterators with until() function

I want to extend generic iterators with a convenience function until() that works like an inversion of take_while(). Here is the ...
Richard Neumann's user avatar
2 votes
1 answer
597 views

A database trait in Rust. How can I make all these generic parameters easier to use?

I am trying to hide the implementation details of accessing a Postgres database. To do this, I want to create "database" and "transaction" traits for use in a repository struct. ...
haz's user avatar
  • 255
1 vote
1 answer
100 views

Minimal list definition in Rust

As a purely pedagogical exercise, I've been trying to use Rust's (very expressive) type system to define the bare minimum one might expect from an ordinary list type. While there's likely a higher-...
jmcph4's user avatar
  • 198
2 votes
1 answer
254 views

Using method trait to return something in laravel model

I have question about scope yesterday, and someone gives an answer to don't return anything in scope. Is return something in scope really bad practice? Should I not return anything in the model ...
Muhammad Dyas Yaskur's user avatar
1 vote
1 answer
49 views

Proper naming for objects which have a position and bounds on a plane

I have an interface which is for an object which has bounds in a 2D plane. ...
Adam Arold's user avatar
0 votes
1 answer
391 views

Scala implicit conversion to add methods to Int

I started learning Scala, and like most functional languages, things get messy pretty quickly for a beginner. Here I have built a wrapper class for Ints so that I ...
smac89's user avatar
  • 1,509
0 votes
1 answer
99 views

Using Traits for set methods

I have an abstract class Consumer: ...
FakeHeal's user avatar
  • 145
2 votes
0 answers
3k views

Laravel 5 Dependency Injecting a Repository into a controller, and depedency injecting an entity into repository

Overview:: I have a Restful API that pushes all /api/{version}/{Repository} into my ResourceV{1}Controller depending on the <...
Dustin Parham's user avatar
12 votes
1 answer
2k views

Macro to build type declaration

These are some macros to help build a traits class (for the parser/printer classes I am building). Traits.h ...
Martin York's user avatar
  • 95.1k
62 votes
3 answers
51k views

Trait accessing variables of classes using it

I just tried PHP Traits for the first time, to keep my code DRY : ...
Marcel Burkhard's user avatar
2 votes
2 answers
3k views

PHP Trait Singleton

An implementation of the singleton pattern in PHP using a trait (added in 5.4). Is there anything missing, any ways to create a second copy of the class? ...
Spencer's user avatar
  • 217