programmingrust / examples Goto Github PK
View Code? Open in Web Editor NEWComplete code for the larger example programs from the book.
License: MIT License
Complete code for the larger example programs from the book.
License: MIT License
Had to run 'Cargo update' for the iron-gcd to run without errors using the cloned repository. Attached is the resulting Cargo.lock file.
I found a small typo in this code, page 317 :
impl<K,V> Hashmap<K,V> where K: Eq + Hash {
fn get<Q: ?Sized>(&self,key: &Q) -> Option<&V>
Where K:Borrow<Q>,
Q: Eq+Hash
{...}
}
The problem is in Where K: Borrow<Q>
it should be Where key: Borrow<Q>
Instead of K
it should be key
.
the code from P.520:
$( fields.insert($crate::ToString::to_string($key), json!($value)); )*
the code in this repository is:
$( fields.insert($crate::macros::ToString::to_string($key), json!($value)); )*
It should use the second version $crate::macros::ToString
because ToString
is private, just like HashMap
?
๐
Hello,
It seems that there is no source code for the quickreplace program.
Could you upload the quickreplace 's code, please?
Running the code around page 18 gives me the following error:
error[E0277]: cannot subtract `chrono::Duration` from `Tm`
cookie.set_expires(time::now() - Duration::days(365));
| ^ no implementation for `Tm - chrono::Duration`
|
= help: the trait `Sub<chrono::Duration>` is not implemented for `Tm`
= help: the following other types implement trait `Sub<Rhs>`:
<Tm as Sub<time::Duration>>
<Tm as Sub>
The compiler doesn't even reach my code, so it must be an issue with dependencies.
Based on this Reddit post, other people are getting the same error:
https://www.reddit.com/r/rust/comments/17djgjd/working_through_programming_rust_2nd_edition_got/
Adding this dependency fixes the issue:
chrono = { version = "= 0.4.29" }
I don't see any license information for this code anywhere. Maybe I'm just missing it?
Hello, I'm having a compiler problem, running on windows 10 with C++ build tools 2017.
Book's Pages: 18-19.
Terminal Output:
$ cargo run
Compiling iron-gdc v0.1.0 (file:///C:/Users/Simone%20Romano/Desktop/git/rust/iron-gdc)
error: cannot find macromime!
in this scope
--> src\main.rs:21:22
|
21 | response.set_mut(mime!(Text/Html; Charset=Utf8));
| ^^^^error: aborting due to previous error
error: Could not compile
iron-gdc
.To learn more, run the command again with --verbose.
Code:
extern crate iron;
#[macro_use] extern crate mime;
use iron::prelude::*;
use iron::status;
fn main()
{
let port = 3000;
let hostname = "localhost:" + port.to_string();
println!("Serving on http://{}...", hostname);
Iron::new(get_form).http(hostname).unwrap;
}
fn get_form(_request: &mut Request) -> IronResult<Response>
{
let mut response = Response::new();
response.set_mut(status::Ok);
response.set_mut(mime!(Text/Html; Charset=Utf8));
response.set_mut(r#"
<title> GDC Calculator </title>
<form action="/gdc" method="post">
<input type="text" name="n">
<input type="text" name="n">
<button type="submit"> Compute GDC </button>
</form>
"#);
Ok(response)
}
The heading: "Chapter 22: Foreign Functions"
should be: "Chapter 23: Foreign Functions"
In the first edition of the book, there is no "Foreign Functions" chapter.
In the second edition of the book, "Foreign Functions" is chapter 23.
Hi, firstly very thanks for your awesome examples :-D
I have a little question about this example: https://github.com/ProgrammingRust/examples/blob/master/cheapo-request/src/main.rs#L11
Can you please tell me why this shutdown is required? I have uncomment this line, but it seems that I can never get response from server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.