Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Learning Rust
Learning Rust

Learning Rust: A comprehensive guide to writing Rust applications

eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Learning Rust

Introducing and Installing Rust

Rust is a fairly new addition to the ever-growing number of programming languages available to developers. If you've never used Rust, but come from pretty much any procedural language (such as C or Pascal) or are used to shell scripting, then you should very quickly feel right at home when using Rust.

Getting to grips with Rust is simple enough, and in this chapter we will cover the following topics:

  • Installing Rust with rustup
  • Testing the installation
  • Setting up a project
  • Looking at the IDEs available
  • Automation using Cargo

Installing Rust

As with most languages, Rust is available for a wide number of platforms. It would be impossible to go through installing the compiler on every variant of every operating system. Fortunately, there's an official method of installing Rust, and even though the details may differ slightly, the process is almost the same on all platforms. Therefore, this book will cover installing Rust using rustup on Fedora 27.

https://rustup.rs always contains up-to-date instructions on how to get going on all platforms. On Linux and macOS, it will look something like this:

On Windows, this text is replaced by a link to rustup-init.exe, which is an executable that installs and sets up rustup on Windows.

Installing rustup on Linux

Run the suggested command that is shown at https://rustup.rs. Run this command in a Terminal. The script suggests some defaults and asks you to confirm them. This is roughly what it should look like after completing the whole script:

Note that this script attempts to set up rustup for your user by editing your .profile and .bash_profile files. If you are using a custom setup, such as another shell, you may need to add the source $HOME/.cargo/env command manually.

After finishing this script, you can verify that it worked by logging off and on from your Terminal and verifying that the tools are in your path:

gcc prerequisites

To build any software that links against external libraries, you will need a C compiler and development versions of any libraries you may be linking against. To ensure that things work properly, install the compiler using the standard method for your operating system.

In Fedora, this would be done using the dnf tool:

sudo dnf install -y gcc

If you are unsure whether you have gcc installed, type the following command in a terminal window:

gcc -version  

If gcc is installed, you'll see something like this:

Testing your installation

Open a command-prompt window and type this:

rustc --version  

If everything was installed correctly, you will see something like this:

Integrated Development Environment

To effectively code Rust, you will need at least some sort of text editor. All popular editors are properly supported, so if your favorite is Vim, Emacs, or any of the others, you will find a high-quality Rust extension there. The website https://areweideyet.com/ should give a current view of how things are.

We will cover the lightweight IDE from Microsoft, Visual Studio Code, and its most current Rust extension, called simply Rust. This IDE should work fairly well in all the different desktop environments. Installation instructions and packages for several platforms are available at Visual Studio Code's main site, https://code.visualstudio.com.

  1. Open up Visual Studio Code and go to the Command Palette, either by the View menu or by the keyboard shortcut Ctrl + Shift + P (which may differ between platforms). Type in install extension to look for the proper command, and then select Install Extensions:
  1. After selecting this, type rust into the next field to look for the Rust extension. At the time of writing, the most recent one is made by kalitaalexey:
  1. You can install Rust right away by pressing Install; alternatively, click on the list item itself to show information about the extension first. After installing it, reload the editor. The Rust extension is now installed and ready to use!

Your first Rust project

Your first Rust project is not going to be particularly amazing. If anything, it's going to serve four purposes:

  • Showing the structure of a Rust project
  • Showing how to create a project by hand
  • Showing how to create a project using the Rust Cargo script
  • Compiling and executing the program

Structure of a Rust project

A Rust project (irrespective of the platform you are developing on) will have the following structure:

The preceding screenshot shows the structure of the simplest Rust project, and as such can be replicated using the following commands:

OS X/Linux

Windows (from the command prompt)

mkdir firstproject cd firstproject touch Cargo.toml mkdir src cd src touch main.rs
md firstproject cd firstproject md src echo $null >> Cargo.toml cd src echo $null >> main.rs
The echo $null >> filename command creates an empty file without the need to start Notepad; save the file and exit.

The Cargo.toml file is the Rust equivalent of a Makefile. When the .toml file is created by hand, it should be edited to contain something like this:

The structure of a Rust project can expand to include documentation as well as the build structure, as follows:

Automating things

While there is nothing wrong with creating a Rust project by hand, Rust does come with a very handy utility called Cargo. Cargo can be used not only to automate the setting up of a project, but also to compile and execute Rust code. Cargo can be used to create the parts required for a library instead of an executable, and can also generate application documentation.

Creating a binary package using Cargo

As with any other script, Cargo works (by default) on the current working directory. (For example, while writing this chapter, my working directory for the example code is ~/Developer/Rust/chapter0 on the Mac and Linux boxes, and J:\Developer\Rust\Chapter0 on the Windows 10 machine.)

In its simplest form, Cargo can generate the correct file structure like this:

cargo new demo_app_name -bin 

The preceding command tells Cargo to create a new structure called demo_app_name, and that it is to be a binary. If you remove -bin, it creates a structure called, which is going to be a library (or more accurately, something other than a binary).

If you don't wish to use the root (say you want to create a library within your binary framework), then instead of demo_app_name, you append the structure before the name relating to your working directory.

In the small example I gave earlier, if I wanted to create a library within my binary structure, I would use the following:

cargo new app_name/mylib  

That will create a structure like this:

The Cargo.toml file requires no editing (at this stage), as it contains the information we had to enter manually when we created the project by hand.

Cargo has a number of directory separator translators. This means that the preceding example can be used on OS X, Linux, and Windows without an issue; Cargo has converted the / to \ for Windows.

Using Cargo to build and run an application

As we are all able to create directory structures, Cargo is then able to build and execute our source code.

If you look at the source code that comes with this chapter, you will find a directory called app_name. To build this package using Cargo, type the following from a Terminal (or command on Windows) window:

cd app_name 
cargo build app_name  

This will build the source code; finally you will be informed that the compilation has been successful:

Next, we can use Cargo to execute the binary as follows:

cargo run

If everything has worked, you will see something like the following:

As with any sort of utility, it's possible to "daisy-chain" the build and execution into one line, as follows:

cargo build; cargo run  
You may be wondering why the first operation performed was to move into the application structure rather than just type cargo build. This is because Cargo is looking for the Cargo.toml file (remember, this acts as a build script).

Cleaning your source tree with Cargo

When the Rust compiler compiles the source files, it generates something known as an object file. The object file takes the source file (which we can read and understand) and compiles this into a form that can be joined with other libraries to create a binary.

This is a good idea, as it cuts down on compilation time; if a source file has not been changed, there is no need to recompile the file, as the object file will be the same.

Sometimes, the object file becomes out of date, or code in another object file causes a panic due to conflicts. In this case, it is not uncommon to "clean" the build. This removes the object files, and the compiler then has to recompile all the source files.

Also, it should always be performed prior to creating a release build.

The standard Unix make program performs this with the clean command (make clean). Cargo performs the clean operation in a way similar to the make utility in Unix:

cargo clean  

A comparison of the directories shows what happens when using the preceding Cargo command:

The entire target directory structure has simply been removed (the preceding screenshot was from a Mac, hence the dSYM and plist files. These do not exist on Linux and Windows).

Creating documentation using Cargo

As with other languages, Rust is able to create documentation based on meta tags with the source files. Take the following example:

fn main() 
{ 
   print_multiply(4, 5); 
} 
 
/// A simple function example 
/// 
/// # Examples 
/// 
/// ``` 
/// print_multiply(3, 5); 
///  
/// ``` 
 
fn print_multiply(x: i32, y: i32) 
{ 
   println!("x * y = {}", x * y); 
} 

The comments preceded by /// will be converted into documentation.

The documentation can be created in one of two ways: via Cargo or by using the rustdoc program.

rustdoc versus Cargo

As with the other operations provided by Cargo, when documentation is created, it acts as a wrapper for rustdoc. The only difference is that with rustdoc you have to specify the directory that the source file sits in. Cargo acts dumb in this case, and creates the documentation for all source files.

In its simplest form, the rustdoc command is used as follows:

cargo doc
rustdoc src/main.rs  

Cargo does have the advantage of creating the doc structure within the root folder, whereas rustdoc creates the structure within the target (which is removed with cargo clean).

Using Cargo to help with your unit testing

Hopefully, unit testing is not something you will be unfamiliar with. A unit test is a test that operates on a specific function or method rather than an entire class or namespace. It ensures that the function operates correctly on the data it is presented with.

Unit tests within Rust are very simple to create (two examples are given in the assert_unittest and unittest directories). The following has been taken from the unittest example:

fn main() { 
    println!("Tests have not been compiled, use rustc --test instead (or cargo test)"); 
} 
 
#[test] 
fn multiply_test() 
{ 
   if 2 * 3 == 5 
   { 
      println!("The multiply worked"); 
   } 
} 

When this is built and executed, you may be surprised by the following result:

The reason why this unit test has passed despite 2 x 3 not being 5 is because the unit test is not testing the result of the operation, but that the operation itself is working. It is very important that this distinction is understood from an early stage to prevent confusion later.

We have hit a limitation of unit testing: if we are not testing the data but the operation, how can we know that the result itself is correct?

Assert yourself!

Unit testing provides the developer with a number of methods called assertion methods:

#[test] 
fn multiply() 
{ 
   assert_eq!(5, 2 * 3); 
} 

In the preceding code snippet, we use the assert_eq! (assert equal) macro. The first argument is the answer expected, and the second argument is what is being tested. If 2 * 3 = 5, then the assertion is true and passes the unit test.

Is there anything Cargo can't do?

For a Rust developer, Cargo is an amazing utility. In addition to these common facilities, it also has other commands, which are listed in the table that follows. All commands follow this form:

cargo <command> <opts>  

Command

What it does

fetch

This command fetches the dependencies of a package from the network. If a lockfile is available, this command will ensure that all of the Git dependencies and/or registry dependencies are downloaded and locally available. The network is never called after a cargo fetch unless the lockfile changes.

If the lockfile is not available, then this is the equivalent of cargo generate-lockfile. A lockfile is generated and all the dependencies are also updated.

generate-lockfile

This command generates the lockfile for a project. The lockfile is typically generated when cargo build is issued (you will see it as Cargo.lockfile in the directory structure).

git-checkout

This command checks out a Git repository. You will need to use it in the following form:

cargo git-checkout -url=URL        
locate-project

This command locates a package.

login

This command saves an API token from the registry locally. The call is in the following form:

cargo login -host=HOST   token        
owner

This command manages the owners of a crate on the registry. This allows the ownership of a crate (a crate is a Rust library) to be altered (--add LOGIN or -remove LOGIN) as well as adding tokens to the crate.

This command will modify the owners for a package on the specified registry (or the default). Note that the owners of a package can upload new versions, yank old versions, and also modify the set of owners, so be cautious!

package

This command assembles the local package into a distributable tarball.

pkgid

This command prints a fully qualified package specification.

publish

This command uploads a package to the registry.

read-manifest

This command reads the manifest file (.toml).

rustc

This command compiles the complete package.

The specified target for the current package will be compiled along with all of its dependencies. The specified options will all be passed to the final compiler invocation, not any of the dependencies. Note that the compiler will still unconditionally receive arguments such as -L, --extern, and --crate-type, and the specified options will simply be added to the compiler invocation.

This command requires that only one target is being compiled. If more than one target is available for the current package, the filters --lib, --bin, and so on—must be used to select which target is compiled.

search

This command searches for packages at https://crates.io/.

update

This command updates dependencies as recorded in the local lockfile.

Typical options are:

  • --package SPEC (package to update)
  • --aggressive (forcibly update all dependencies of <name> as well)
  • --precise PRECISE (update a single dependency to exactly PRECISE)

This command requires that a Cargo.lock file already exists as generated by cargo build or related commands.

If a package spec name (SPEC) is given, then a conservative update of the lockfile will be performed. This means that only the dependency specified by SPEC will be updated. Its transitive dependencies will be updated only if SPEC cannot be updated without updating the dependencies. All other dependencies will remain locked at their currently recorded versions.

If PRECISE is specified, then --aggressive must not also be specified. The argument PRECISE is a string representing a precise revision that the package being updated should be updated to. For example, if the package comes from a Git repository, then PRECISE would be the exact revision that the repository should be updated to.

If SPEC is not given, then all the dependencies will be re-resolved and updated.

verify-project

This command ensures that the project is correctly created.

version

This command shows the version of Cargo.

yank

This command removes a pushed crate from the index.

The yank command removes a previously pushed crate version from the server's index. This command does not delete any data, and the crate will still be available for download via the registry's download link.

Note that existing crates locked to a yanked version will still be able to download the yanked version to use it. Cargo will, however, not allow any new crates to be locked to any yanked version.

 

As you can now appreciate, the Cargo utility script is extremely powerful and flexible.

Summary

We now have a fully working installation of Rust, and are ready for the get-go. We've explained how to set up a project, both manually and via the Cargo utility, and you should already have an appreciation of how useful Cargo is.

In the next chapter, we'll be looking at the foundation of any language: variables.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Get started with the language to build scalable and high performance applications
  • This book will help C#/C++ developers gain better performance and memory management
  • Discover the power of Rust when developing concurrent applications for large and scalable software

Description

Rust is a highly concurrent and high performance language that focuses on safety and speed, memory management, and writing clean code. It also guarantees thread safety, and its aim is to improve the performance of existing applications. Its potential is shown by the fact that it has been backed by Mozilla to solve the critical problem of concurrency. Learning Rust will teach you to build concurrent, fast, and robust applications. From learning the basic syntax to writing complex functions, this book will is your one stop guide to get up to speed with the fundamentals of Rust programming. We will cover the essentials of the language, including variables, procedures, output, compiling, installing, and memory handling. You will learn how to write object-oriented code, work with generics, conduct pattern matching, and build macros. You will get to know how to communicate with users and other services, as well as getting to grips with generics, scoping, and more advanced conditions. You will also discover how to extend the compilation unit in Rust. By the end of this book, you will be able to create a complex application in Rust to move forward with.

Who is this book for?

The book is for absolute beginners to Rust, who want to build high performance, concurrent applications for their projects. It is suitable for developers who have a basic knowledge of programming and developers who are using the C#/C++ language to write their applications. No knowledge of Rust is expected.

What you will learn

  • Set up Rust for Windows, Linux, and OS X
  • Write effective code using Rust
  • Expand your Rust applications using libraries
  • Interface existing non-Rust libraries with your Rust applications
  • Use the standard library within your applications
  • Understand memory management within Rust and speed efficiency when passing variables
  • Create more complex data types
  • Study concurrency in Rust with multi-threaded applications and sync threading techniques to improve the performance of an application problem
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 24, 2017
Length: 308 pages
Edition : 1st
Language : English
ISBN-13 : 9781785884306
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Publication date : Nov 24, 2017
Length: 308 pages
Edition : 1st
Language : English
ISBN-13 : 9781785884306
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 146.97
Rust Essentials
$48.99
Learning Rust
$48.99
Rust Programming By Example
$48.99
Total $ 146.97 Stars icon
Banner background image

Table of Contents

14 Chapters
Introducing and Installing Rust Chevron down icon Chevron up icon
Variables Chevron down icon Chevron up icon
Input and Output Chevron down icon Chevron up icon
Conditions, Recursion, and Loops Chevron down icon Chevron up icon
Remember, Remember Chevron down icon Chevron up icon
Creating Your Own Rust Applications Chevron down icon Chevron up icon
Matching and Structures Chevron down icon Chevron up icon
The Rust Application Lifetime Chevron down icon Chevron up icon
Introducing Generics, Impl, and Traits Chevron down icon Chevron up icon
Creating Your Own Crate Chevron down icon Chevron up icon
Concurrency in Rust Chevron down icon Chevron up icon
Now It&#x27;s Your Turn! Chevron down icon Chevron up icon
The Standard Library Chevron down icon Chevron up icon
Foreign Function Interfaces Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(87 Ratings)
5 star 58.6%
4 star 34.5%
3 star 2.3%
2 star 3.4%
1 star 1.1%
Filter icon Filter
Top Reviews

Filter reviews by




Ahti Nurme Dec 12, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Udemy Verified review Udemy
Amnat Promngam Dec 21, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Udemy Verified review Udemy
Dr. Christian Dury Dec 13, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Udemy Verified review Udemy
Magne Alvheim Oct 24, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Udemy Verified review Udemy
Chan Pak Hong Aug 16, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It's great
Udemy Verified review Udemy
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela