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

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

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

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

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

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

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

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

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

Using Traits for set methods

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

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

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

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

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