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.
13 questions
2
votes
0
answers
87
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 ...
4
votes
1
answer
166
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 ...
0
votes
1
answer
123
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 ...
2
votes
1
answer
732
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. ...
1
vote
1
answer
114
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-...
3
votes
1
answer
328
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 ...
1
vote
1
answer
84
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.
...
0
votes
1
answer
439
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 ...
0
votes
1
answer
118
views
Using Traits for set methods
I have an abstract class Consumer:
...
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 <...
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
...
62
votes
3
answers
52k
views
Trait accessing variables of classes using it
I just tried PHP Traits for the first time, to keep my code DRY :
...
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?
...