"Oui je développe en Rust, comment t'as su?"

saddeveloper
2021-04-09 16:48:41

En effet, oui, j'apprécie ce langage, cela fait des années que je n'ai pas touché à du C ou à du C++.https://image.noelshack.com/fichiers/2020/20/1/1589149502-gigachad-en-peau-de-genou.png
Sinon toi ça va? Tu fais encore du c++ non?

- Heu attend j'ai un truc à reglerhttps://image.noelshack.com/fichiers/2017/14/1491656358-risijd.png
https://image.noelshack.com/fichiers/2021/14/5/1617979344-image.pngmh...https://image.noelshack.com/fichiers/2016/47/1480183054-1472051444-risitas-sueur.jpg
In file included from /usr/include/c++/4.6/algorithm:63:0,
from error_code.cpp:2:
/usr/include/c++/4.6/bits/stl_algo.h: In function ‘_RandomAccessIterator std::__find(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator*, std::vector > >, _Tp = int]’:
/usr/include/c++/4.6/bits/stl_algo.h:4403:45: instantiated from ‘_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator*, std::vector > >, _Tp = int]’
error_code.cpp:8:89: instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:162:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:162:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:4403:45: instantiated from ‘_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator*, std::vector > >, _Tp = int]’
error_code.cpp:8:89: instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:166:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:166:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:170:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:170:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:174:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:174:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:182:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:182:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:186:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:186:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_algo.h:190:4: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator::operator* [with _Iterator = std::vector*, _Container = std::vector >, __gnu_cxx::__normal_iterator::reference = std::vector&]() == __val’
/usr/include/c++/4.6/bits/stl_algo.h:190:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template bool std::operator==(const std::pair&, const std::pair&)
/usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template bool std::operator==(const std::reverse_iterator&, const std::reverse_iterator&)
/usr/include/c++/4.6/bits/allocator.h:122:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/allocator.h:127:5: note: template bool std::operator==(const std::allocator&, const std::allocator&)
/usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template bool std::operator==(const std::vector&, const std::vector&)
/usr/include/c++/4.6/ext/new_allocator.h:123:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator&, const __gnu_cxx::new_allocator&)
/usr/include/c++/4.6/bits/stl_iterator.h:805:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)
/usr/include/c++/4.6/bits/stl_iterator.h:799:5: note: template bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator&, const __gnu_cxx::__normal_iterator&)

merdehttps://image.noelshack.com/fichiers/2016/47/1480183054-1472051444-risitas-sueur.jpg

- Bon je te laisse Celestin, naturlig udvælgelse.https://image.noelshack.com/fichiers/2020/20/1/1589149502-gigachad-en-peau-de-genou.png

- Quoi?https://image.noelshack.com/fichiers/2016/38/1474551360-1474388957-picsart-09-21-06-24-26.png

- Je voulais dire bonne chance à toi.https://image.noelshack.com/fichiers/2020/20/1/1589149502-gigachad-en-peau-de-genou.png

Hibou440
2021-04-09 16:50:10

c'est bon c'est que des warning non :hap:

saddeveloper
2021-04-09 17:08:19

Le 09 avril 2021 à 16:50:10 :
c'est bon c'est que des warning non :hap:

ui

Scarlett-V6
2021-04-09 17:09:36

ça divise par 0 et ça se dit développeur :rire:

saddeveloper
2021-04-09 18:33:28

[17:09:36] <Scarlett-V6>
ça divise par 0 et ça se dit développeur :rire:

ok mais t kient

Jency18
2021-04-09 18:37:49

C'est pas la faute de C++, c'est la faute du compilateur :ok:

ProloJusquaLOs
2021-04-09 19:40:01

enum Fb {
Fizz,
Buzz,
FizzBuzz(u64)
}

fn main() {
use Fb::*;
let fb_fibo_map: std::collections::HashMap<_, _> = (0..=30)
.scan((0, 1), |s, i| { *s = (s.0 + s.1, s.0); (i, s.1).into() })
.filter_map(|(i, v)| match (i % 3, i % 5) {
(0, 0) => (i, FizzBuzz(v)).into(),
(0, _) => (i, Fizz).into(),
(_, 0) => (i, Buzz).into(),
_ => None
})
.collect();

for (k, v) in fb_fibo_map {
match v {
Fizz => println!("{} is a Fizz", k),
Buzz => println!("{} is a Buzz", k),
FizzBuzz(fibo) => println!("fibo({}) = {}", k, fibo)
}
}
}

/*9 is a Fizz
6 is a Fizz
25 is a Buzz
fibo(15) = 610
20 is a Buzz
fibo(0) = 0
24 is a Fizz
21 is a Fizz
27 is a Fizz
5 is a Buzz
10 is a Buzz
fibo(30) = 832040
18 is a Fizz
3 is a Fizz
12 is a Fizz*/

me a scholarhttps://image.noelshack.com/fichiers/2017/04/1485268586-hackeur-v1.png

ProloJusquaLOs
2021-04-09 19:44:55

Le 09 avril 2021 à 18:37:49 :
C'est pas la faute de C++, c'est la faute du compilateur :ok:

Alors en fait non, c'est absolument la faute de C++ et de son système de templates qui repose sur du duck typing et le SFINAE. Le problème est réglé avec les concepts. Et Rust n'a pas le problème grâce aux traits.
Certes, un compilateur extrêmement intelligent (vraiment) pourrait afficher une information potentiellement plus utile, mais ce n'est pas décidable de façon générale.

saddeveloper
2021-04-10 20:45:39

Le 09 avril 2021 à 19:40:01 a écrit :
<code>enum Fb {
Fizz,
Buzz,
FizzBuzz(u64)
}

fn main() {
use Fb::*;
let fb_fibo_map: std::collections::HashMap<_, _> = (0..=30)
.scan((0, 1), |s, i| { *s = (s.0 + s.1, s.0); (i, s.1).into() })
.filter_map(|(i, v)| match (i % 3, i % 5) {
(0, 0) => (i, FizzBuzz(v)).into(),
(0, _) => (i, Fizz).into(),
(_, 0) => (i, Buzz).into(),
_ => None
})
.collect();

for (k, v) in fb_fibo_map {
match v {
Fizz => println!("{} is a Fizz", k),
Buzz => println!("{} is a Buzz", k),
FizzBuzz(fibo) => println!("fibo({}) = {}", k, fibo)
}
}
}

/*9 is a Fizz
6 is a Fizz
25 is a Buzz
fibo(15) = 610
20 is a Buzz
fibo(0) = 0
24 is a Fizz
21 is a Fizz
27 is a Fizz
5 is a Buzz
10 is a Buzz
fibo(30) = 832040
18 is a Fizz
3 is a Fizz
12 is a Fizz*/</code>

me a scholarhttps://image.noelshack.com/fichiers/2017/04/1485268586-hackeur-v1.png

j'ai rien compris ayaa

ProloJusquaLOs
2021-04-10 22:47:58

Le 10 avril 2021 à 20:45:39 :

Le 09 avril 2021 à 19:40:01 a écrit :
<code>enum Fb {
Fizz,
Buzz,
FizzBuzz(u64)
}

fn main() {
use Fb::*;
let fb_fibo_map: std::collections::HashMap<_, _> = (0..=30)
.scan((0, 1), |s, i| { *s = (s.0 + s.1, s.0); (i, s.1).into() })
.filter_map(|(i, v)| match (i % 3, i % 5) {
(0, 0) => (i, FizzBuzz(v)).into(),
(0, _) => (i, Fizz).into(),
(_, 0) => (i, Buzz).into(),
_ => None
})
.collect();

for (k, v) in fb_fibo_map {
match v {
Fizz => println!("{} is a Fizz", k),
Buzz => println!("{} is a Buzz", k),
FizzBuzz(fibo) => println!("fibo({}) = {}", k, fibo)
}
}
}

/*9 is a Fizz
6 is a Fizz
25 is a Buzz
fibo(15) = 610
20 is a Buzz
fibo(0) = 0
24 is a Fizz
21 is a Fizz
27 is a Fizz
5 is a Buzz
10 is a Buzz
fibo(30) = 832040
18 is a Fizz
3 is a Fizz
12 is a Fizz*/</code>

me a scholarhttps://image.noelshack.com/fichiers/2017/04/1485268586-hackeur-v1.png

j'ai rien compris ayaa

Pour de vrai ?
Le but c'est juste de faire du code qui ne sert à rien (un FizzBuzz) de façon ridicule en mettant en exergue quelques magnifiques pans du langage.
Tu itères de 0 à 30 (de façon lazy bien entendu) et calcules pour chaque indice i fibonacci(i) grâce à la réduction "scan".
Ensuite, tu filtres la suite pour ne garder que les Fizz, les Buzz et les FizzBuzz grâce à un "filter_map", du pattern matching et l'auto implémentation de std::convert::Into<Option<T>> pour T.
Pour le fun, tu montres la puissance de "collect" en balançant la sortie dans une HashMap dont tu ne spécifies pas les paramètres pour faire une démo de la déduction de type.
Tu finis avec une simple itération + pattern matching pour utiliser ta HashMap, mais franchement c'est nul, je pense qu'il y aurait plus rigolo à faire.

Infos
Gestion du forum

contact@geevey.com

API disponible. Utilisez le paramètre "api" en GET, peu importe le contenu, sur une page du site.

Notes

    Partenaire: JVFlux
    Ce site n'est pas associé à Jeuxvideo.com ou Webedia. Nous utilisons seulement des archives publiques.
    Il est inutile de me spammer par e-mail pour supprimer un topic. Au contraire, en conséquence, je mettrais votre topic dans le bloc ci-dessous.
Non-assumage
    Personne n'a pas assumé de topic pour le moment.