Comments (8)
@stevejb71 @petertseng @NobbZ -- do you have any ideas about how we could solve this?
from rust.
To be honest, this is the exercise I'm stuck with too, I don't even know
why I'm called in here 😁
But yes, here the tests do a very strongly depend on the data structure
where possibly is no need for.
Also for the sake of the exercise it should not matter if you use the named
fields or tuple syntax.
Anyway, I will take a closer look tomorrow when I'm back at my laptop and
no one else chimed in.
Katrina Owen [email protected] schrieb am Mo., 11. Jan. 2016 20:26:
@stevejb71 https://github.com/stevejb71 @petertseng
https://github.com/petertseng @NobbZ https://github.com/NobbZ -- do
you have any ideas about how we could solve this?—
Reply to this email directly or view it on GitHub
#64 (comment).
from rust.
@NobbZ I called you because you've commented a lot in the rust track :)
from rust.
@kytrinyx A reasonable approach is taken here.
from rust.
Yeah, that looks good.
from rust.
Yeah, the expected interface being thrown in a comment somewhere seems good. Probably in the stub file would be in a more visible location than the test file, even?
On a related note, I've been trying to think about getting tests to be less constraining of implementation details these days. Do you think doing Allergies(0)
is too constraining and it should be Allergies::new(0)
instead?
(and the example impl can just have fn new(n: uint) -> Allergies { Allergies(n) }
or similar, and anyone else can do whatever they want)
from rust.
Yeah, one could give a list of functions and signatures in the impl, thats one good thing, but not the solution to the OPs problem.
The OP assumed the design of the type would be as usual. So he designed a struct using record-syntax and used a static function new
in the impl to create new values of the type. This is quite a common pattern in rust.
There is another kind of structs, using tuplesyntax. There fields don't have a name, and the structs name is used as if it were the new
function.
Both have some pros and cons, eg tuplesyntax is much nicer to pattern match on, while recordsyntax is much more self documenting due to the named fields.
I have seen both in the wild, but the section about tuple syntax in the official rust manual is very short, while record syntax is explained exhaustively.
So I'd prefer to not make any assumption in any future tests that make assumptions about the used syntax, but always use a static constructor in the impl and document signature as shown above.
from rust.
So I'd prefer to not make any assumption in any future tests that make assumptions about the used syntax, but always use a static constructor in the impl and document signature as shown above.
Agree.
from rust.
Related Issues (20)
- Improve example solution testing scripts
- CamelCase test unintentionally removed from acronym exercise HOT 2
- Building a training set of tags for rust HOT 25
- Tests fail with no output HOT 16
- Tests don't pass when sending Cargo.toml with optional dependency HOT 1
- Remove all util functions from test files HOT 6
- Test in CI that stubs don't generate clippy warnings HOT 1
- Move more CI tests to rust tooling
- Concepts for this track are not displayed HOT 1
- word-count: change interface from u32 to usize
- test type_override fails even when correct solution is made in macros lesson HOT 1
- Performance issue about the Isogram problem approach HOT 1
- Add test that templates match generated test suite HOT 5
- One of two-bucket's test case is wrong HOT 3
- Improve exercise order HOT 1
- new test case for Phone Number HOT 2
- Wrong source link in the exercise `Reverse String` HOT 2
- protein-translation: adds extra codons without mentioning them in instructions HOT 2
- protein-translation: slightly confusing setup HOT 7
- grep exercise fails with implementation using clap on the grader HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.