Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

The Complete Rust Programming

Reference Guide Rahul Sharma


Visit to download the full and correct content document:
https://textbookfull.com/product/the-complete-rust-programming-reference-guide-rahu
l-sharma/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Mastering Delphi Programming A Complete Reference Guide


Primož Gabrijel■i■

https://textbookfull.com/product/mastering-delphi-programming-a-
complete-reference-guide-primoz-gabrijelcic/

The Rust Programming Language Covers Rust 2018 Steve


Klabnik

https://textbookfull.com/product/the-rust-programming-language-
covers-rust-2018-steve-klabnik/

The Rust Programming Language 1st Edition Steve Klabnik

https://textbookfull.com/product/the-rust-programming-
language-1st-edition-steve-klabnik/

The Rust Programming Language 2nd Edition Steve Klabnik

https://textbookfull.com/product/the-rust-programming-
language-2nd-edition-steve-klabnik/
Programming Rust 1st Edition Jim Blandy

https://textbookfull.com/product/programming-rust-1st-edition-
jim-blandy/

Environmental Issues of Deep Sea Mining Impacts


Consequences and Policy Perspectives Rahul Sharma

https://textbookfull.com/product/environmental-issues-of-deep-
sea-mining-impacts-consequences-and-policy-perspectives-rahul-
sharma/

Programming Rust Fast Safe Systems Development Jim


Blandy

https://textbookfull.com/product/programming-rust-fast-safe-
systems-development-jim-blandy/

Programming WebAssembly with Rust 1st Edition Kevin


Hoffman

https://textbookfull.com/product/programming-webassembly-with-
rust-1st-edition-kevin-hoffman/

Programming Rust, 2nd Edition (Early Release) Jim


Blandy

https://textbookfull.com/product/programming-rust-2nd-edition-
early-release-jim-blandy/
The Complete Rust Programming Reference Guide

Design, develop, and deploy effective software systems using the


advanced constructs of Rust

Rahul Sharma
Vesa Kaihlavirta
Claus Matzinger

BIRMINGHAM - MUMBAI
The Complete Rust
Programming Reference
Guide

Copyright © 2019 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored


in a retrieval system, or transmitted in any form or by any means,
without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure
the accuracy of the information presented. However, the information
contained in this book is sold without warranty, either express or
implied. Neither the authors, nor Packt Publishing or its dealers and
distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information


about all of the companies and products mentioned in this book by
the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.

First published: May 2019


Production reference: 1200519

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-83882-810-3

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


Packt.com
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.packt.com and as a print book customer, you are
entitled to a discount on the eBook copy. Get in touch with us at
customercare@packtpub.com for more details.

At www.packt.com, you can also read a collection of free technical


articles, sign up for a range of free newsletters, and receive
exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
Rahul Sharma is passionately curious about teaching
programming. He has been writing software for the last two years.
He got started with Rust with his work on Servo, a browser engine
by Mozilla Research as part of his GSoC project. At present, he
works at
AtherEnergy, where he is building resilient cloud infrastructure for
smart scooters. His interests include systems programming,
distributed systems, compilers and type theory. He is also an
occasional contributor to the Rust language and does mentoring of
interns on the Servo project by Mozilla.

Vesa Kaihlavirta has been programming since he was five,


beginning with C64 Basic. His main professional goal in life is to
increase awareness of programming languages and software quality
in all industries that use software. He's an Arch Linux Developer
Fellow, and has been working in the telecom and financial industry
for a decade. Vesa lives in Jyvaskyla, central Finland.

Claus Matzinger is a software engineer with a very diverse


background. After working in a small company maintaining code for
embedded devices, he joined a large corporation to work on legacy
Smalltalk applications. This led to a great interest in
programming languages early on, and Claus became the CTO for a
health games start-up based on Scala technology. Since then, Claus'
roles have shifted toward customer-facing roles in the IoT database
technology start-up crate.io and, most recently, Microsoft. There, he
hosts a podcast, writes code together with customers, and blogs
about the solutions arising from these engagements. For more than
5 years, Claus has implemented software to help
customers innovate, achieve, and maintain success.
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit autho
rs.packtpub.com and apply today. We have worked with thousands of

developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are
recruiting an author for, or submit your own idea.
Table of Contents
Title Page

Copyright

The Complete Rust Programming Reference Guide

About Packt

Why subscribe?

Packt.com

Contributors

About the authors

Packt is searching for authors like you

Preface
Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

1. Getting Started with Rust

What is Rust and why should you care?

Installing the Rust compiler and toolchain

Using rustup.rs

A tour of the language

Primitive types

Declaring variables and immutability


Functions

Closures

Strings

Conditionals and decision making

Match expressions

Loops

User-defined types
Structs

Enums

Functions and methods on types

Impl blocks on structs

Impl blocks for enums

Modules, imports, and use statements

Collections

Arrays

Tuples

Vectors

Hashmaps

Slices

Iterators

Exercise – fixing the word counter

Summary

2. Managing Projects with Cargo

Package managers

Modules

Nested modules

File as a module

Directory as module

Cargo and crates

Creating a new Cargo project


Cargo and dependencies

Running tests with Cargo


Running examples with Cargo

Cargo workspace
Extending Cargo and tools

Subcommands and Cargo installation


cargo-watch

cargo-edit
cargo-deb

cargo-outdated
Linting code with clippy

Exploring the manifest file – Cargo.toml


Setting up a Rust development environment
Building a project with Cargo – imgtool
Summary

3. Tests, Documentation, and Benchmarks


Motivation for testing

Organizing tests
Testing primitives

Attributes
Assertion macros

Unit tests
First unit test

Running tests
Isolating test code

Failing tests
Ignoring tests

Integration tests
First integration test

Sharing common code


Documentation

Writing documentation
Generating and viewing documentation

Hosting documentation
Doc attributes

Documentation tests
Benchmarks

Built-in micro-benchmark harness


Benchmarking on stable Rust

Writing and testing a crate – logic gate simulator


Continuous integration with Travis CI

Summary
4. Types, Generics, and Traits

Type systems and why they matter


Generics

Creating generic types


Generic functions

Generic types
Generic implementations
Using generics
Abstracting behavior with traits

Traits
The many forms of traits

Marker traits
Simple traits
Generic traits

Associated type traits


Inherited traits
Using traits with generics – trait bounds
Trait bounds on types

Trait bounds on generic functions and impl blocks


Using + to compose traits as bounds
Trait bounds with impl trait syntax
Exploring standard library traits

True polymorphism using trait objects


Dispatch
Trait objects
Summary

5. Memory Management and Safety


Programs and memory
How do programs use memory?
Memory management and its kinds

Approaches to memory allocation


The stack
The heap
Memory management pitfalls

Memory safety
Trifecta of memory safety
Ownership
A brief on scopes

Move and copy semantics


Duplicating types via traits
Copy
Clone

Ownership in action
Borrowing
Borrowing rules
Borrowing in action

Method types based on borrowing


Lifetimes
Lifetime parameters

Lifetime elision and the rules


Lifetimes in user defined types
Lifetime in impl blocks
Multiple lifetimes

Lifetime subtyping
Specifying lifetime bounds on generic types
Pointer types in Rust
References – safe pointers

Raw pointers
Smart pointers
Drop
Deref and DerefMut

Types of smart pointers


Box<T>
Reference counted smart pointers
Rc<T>

Interior mutability
Cell<T>
RefCell<T>
Uses of interior mutability

Summary
6. Error Handling
Error handling prelude
Recoverable errors

Option
Result
Combinators on Option/Result
Common combinators

Using combinators
Converting between Option and Result
Early returns and the ? operator
Non-recoverable errors

User-friendly panics
Custom errors and the Error trait
Summary
7. Advanced Concepts

Type system tidbits


Blocks and expressions
Let statements
Loop as an expression

Type clarity and sign distinction in numeric types


Type inference
Type aliases
Strings

Owned strings – String


Borrowed strings – &str
Slicing and dicing strings
Using strings in functions

Joining strings
When to use &str versus String ?
Global values
Constants

Statics
Compile time functions – const fn
Dynamic statics using the lazy_static! macro
Iterators

Implementing a custom iterator


Advanced types
Unsized types
Function types

Never type ! and diverging functions


Unions
Cow
Advanced traits

Sized and ?Sized


Borrow and AsRef
ToOwned
From and Into

Trait objects and object safety


Universal function call syntax
Trait rules
Closures in depth

Fn closures
FnMut closures
FnOnce closures
Consts in structs, enums, and traits

Modules, paths, and imports


Imports

Re-exports

Selective privacy
Advanced match patterns and guards

Match guards

Advanced let destructure


Casting and coercion

Types and memory


Memory alignment

Exploring the std::mem module

Serialization and deserialization using serde


Summary

8. Concurrency

Program execution models


Concurrency

Approaches to concurrency
Kernel-based

User-level

Pitfalls
Concurrency in Rust

Thread basics

Customizing threads
Accessing data from threads

Concurrency models with threads


Shared state model
Shared ownership with Arc

Mutating shared data from threads


Mutex

Shared mutability with Arc and Mutex

RwLock
Communicating through message passing

Asynchronous channels
Synchronous channels

thread-safety in Rust

What is thread-safety?
Traits for thread-safety

Send

Sync
Concurrency using the actor model

Other crates
Summary

9. Metaprogramming with Macros

What is metaprogramming?
When to use and not use Rust macros

Macros in Rust and their types

Types of macros
Creating your first macro with macro_rules!

Built-in macros in the standard library


macro_rules! token types

Repetitions in macros

A more involved macro – writing a DSL for HashMap initializat


ion

Macro use case – writing tests

Exercises
Procedural macros

Derive macros

Debugging macros
Useful procedural macro crates

Summary
10. Unsafe Rust and Foreign Function Interfaces

What is safe and unsafe really?


Unsafe functions and blocks
Unsafe traits and implementations

Calling C code from Rust

Calling Rust code from C


Using external C/C++ libraries from Rust

Creating native Python extensions with PyO3


Creating native extensions in Rust for Node.js

Summary

11. Logging
What is logging and why do we need it?

The need for logging frameworks

Logging frameworks and their key features


Approaches to logging

Unstructured logging
Structured logging

Logging in Rust

log – Rust's logging facade


The env_logger

log4rs

Structured logging using slog


Summary

12. Network Programming in Rust


Network programming prelude

Synchronous network I/O

Building a synchronous redis server


Asynchronous network I/O

Async abstractions in Rust

Mio
Futures

Tokio
Building an asynchronous redis server

Summary

13. Building Web Applications with Rust


Web applications in Rust

Typed HTTP with Hyper

Hyper server APIs – building a URL shortener 


hyper as a client – building a URL shortener client

Web frameworks
Actix-web basics

Building a bookmarks API using Actix-web

Summary
14. Lists, Lists, and More Lists

Linked lists

A transaction log
Adding entries

Log replay
After use

Wrap up

Upsides
Downsides

Doubly linked list

A better transaction log


Examining the log

Reverse
Wrap up

Upsides

Downsides
Skip lists

The best transaction log

The list
Adding data

Leveling up
Jumping around

Thoughts and discussion

Upsides
Downsides

Dynamic arrays

Favorite transactions
Internal arrays

Quick access
Wrap up

Upsides
Downsides
Summary

Further reading

15. Robust Trees


Binary search tree

IoT device management


More devices

Finding the right one

Finding all devices


Wrap up

Upsides

Downsides
Red-black tree

Better IoT device management


Even more devices

Balancing the tree

Finding the right one, now


Wrap up

Upsides

Downsides
Heaps

A huge inbox
Getting messages in

Taking messages out

Wrap up
Upsides

Downsides

Trie
More realistic IoT device management

Adding paths
Walking

Wrap up

Upsides
Downsides

B-Tree

An IoT database
Adding stuff

Searching for stuff


Walking the tree

Wrap up

Upsides
Downsides

Graphs

The literal Internet of Things


Neighborhood search

The shortest path

Wrap up
Upsides

Downsides
Summary

16. Exploring Maps and Sets

Hashing
Create your own

Message digestion

Wrap up
Maps

A location cache
The hash function

Adding locations

Fetching locations
Wrap up

Upsides

Downsides
Sets

Storing network addresses


Networked operations

Union

Intersection
Difference

Wrap up

Upsides
Downsides
Summary
Further reading

17. Collections in Rust

Sequences
Vec<T> and VecDeque<T>

Architecture

Insert
Look up

Remove
LinkedList<T>

Architecture

Insert
Look up

Remove

Wrap up
Maps and sets

HashMap and HashSet


Architecture

Insert

Lookup
Remove

BTreeMap and BTreeSet

Architecture
Insert

Look up

Remove

Wrap up
Summary

Further reading

18. Algorithm Evaluation

The Big O notation

Other people's code


The Big O

Asymptotic runtime complexity

Making your own

Loops
Recursion
Complexity classes

O(1)

O(log(n))

O(n)

O(n log(n))

O(n²)
O(2n)

Comparison

In the wild

Data structures

Everyday things
Exotic things

Summary

Further reading

19. Ordering Things

From chaos to order


Bubble sort

Shell sort

Heap sort

Merge sort

Quicksort

Summary
Further reading

20. Finding Stuff

Finding the best

Linear searches

Jump search
Binary searching

Wrap up

Summary

Further reading

21. Random and Combinatorial


Pseudo-random numbers

LCG

Wichmann-Hill
The rand crate

Back to front

Packing bags or the 0-1 knapsack problem


N queens

Advanced problem solving

Dynamic programming

The knapsack problem improved

Metaheuristic approaches
Example metaheuristic – genetic algorithms

Summary

Further reading

22. Algorithms of the Standard Library

Slicing and iteration


Iterator

Slices

Search

Linear search

Binary search

Sorting
Stable sorting

Unstable sorting

Summary

Further reading

Other Books You May Enjoy


Leave a review - let other readers know what you think
Preface
Rust is a powerful language with a rare combination of safety,
speed, and zero-cost abstractions. This Learning Path is filled with
clear and simple explanations of its features along with real-world
examples, demonstrating how you can build robust, scalable, and
reliable programs.

You'll get started with an introduction to Rust data structures,


algorithms, and essential language constructs. Next, you will
understand how to store data using linked lists, arrays, stacks, and
queues. You'll also learn to implement sorting and searching
algorithms, such as Brute Force algorithms, Greedy algorithms,
Dynamic Programming, and Backtracking. As you progress, you'll
pick up on using Rust for systems programming, network
programming, and the web. You'll then move on to discover a variety
of techniques, right from writing memory-safe code, to building
idiomatic Rust libraries, and even advanced macros.

By the end of this Learning Path, you'll be able to implement Rust


for enterprise projects, writing better tests and documentation,
designing for performance, and creating idiomatic Rust code.

This Learning Path includes content from the following Packt


products:

Mastering Rust - Second Edition by Rahul Sharma and Vesa


Kaihlavirta
Hands-On Data Structures and Algorithms with Rust by Claus
Matzinger
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Peck's Bad Boy in
an airship
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Peck's Bad Boy in an airship

Author: George W. Peck

Illustrator: Charles Lederer

Release date: November 27, 2023 [eBook #72237]

Language: English

Original publication: Chicago: Stanton and Van Vliet Co, 1908

Credits: Stephen Hutcheson, Gísli Valgeirsson, Rod Crawford, Dave


Morgan and the Online Distributed Proofreading Team at
https://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK PECK'S BAD


BOY IN AN AIRSHIP ***
PECK’S BAD BOY IN AN
AIRSHIP
“Take That from Your Little Hennery.”
Peck’s Bad Boy
in an Airship
By Hon. Geo. W. Peck
Author of Peck’s Bad Boy, Peck’s Bad Boy Abroad, Peck’s Bad Boy
With the Circus, Peck’s Bad Boy With the Cowboys, Etc.

Humorous and Interesting


A story relating the adventures of Peck’s Bad Boy and
His Pa who are sent to Europe to investigate airships
with an idea of using them in the United States Navy.
Tells of their adventures in Europe also in South Africa
where the airship is used in hunting wild animals.

Illustrated by Charles Lederer


The Celebrated Illustrator and Cartoonist
Copyright, 1908
By W. G. CHAPMAN

Copyright, 1908
By THOMPSON & THOMAS
CONTENTS.

CHAPTER I.
The Bad Boy Wants to Be an Orphan—The Bad Boy Goes to an Orphan
Asylum—The Government Gives the Bad Boy’s Pa an Appointment to
Travel Over the World and Get Information About Airships, Dirigible
Balloons and Everything to Help Our Government Know What Other
Governments are Doing in Case of War 15

CHAPTER II.
No Encouragement for Inventive Genius in Orphan Home—The Boy Uses
His New Invention, a Patent Clothes Wringer, in Milking 28

CHAPTER III.
The Boy Escapes from Orphan Asylum—The Boy and His Chum Had Red
Letter Days—The Boy is Adopted by New Friends 42

CHAPTER IV.
A Bad Railroad Wreck—The Boy Contrasts Their Ride to One in a Parlor
Car—The Lawyer is the Greatest Man on Earth—The Boy Settles His
Claim for $20 55

CHAPTER V.
The Bad Boy Leaves St. Louis in a Balloon—The Boy Makes a Trip to San
Francisco and Joins Evans’ Fleet—The Police Arrest Boy and Tie Up
Balloon 67

CHAPTER VI.
The Balloon Lands in Delaware—The Boy Visits the Battleships—They 78
Scour the Boy With a Piece of Brick and Some Laundry Soap—The Boy
Investigates the Mechanism of the Battleships—The Boy Goes With the
Ships as a Mascot

CHAPTER VII.
A Storm Comes from the Coast of Cuba—Everyone Goes to Sleep on the
Ship Except the Watchman and Pilot—The Bad Boy is Put in the
Dungeon—The Captain Says to Throw the Boy Overboard to Feed the
Sharks 91

CHAPTER VIII.
The Boy Dresses Up in His Sunday Clothes and Tells the Captain He is
Ready to Die—The Crew Throw a Steer Overboard to Feed a School of
Sharks—The Boy Produces His New Electric Battery—The Bad Boy
Makes a Trip to France to Meet His Pa 104

CHAPTER IX.
The Bad Boy Arrives in France—The Boy’s Pa is Suspected of Being an
Anarchist—The Boy Finds Pa Seated at a Large Table Bragging About
America—He Told Them the Men in America Were All Millionaires and
Unmarried 131

CHAPTER X.
Pa Had the Hardest Time of His Life in Paris—Pa Drinks Some Goat Milk
Which Gives Him Ptomaine Poison in His Inside Works—Pa Attends the
Airship Club in the Country—Pa Draws on American Government for
$10,000 145

CHAPTER XI.
The Boy and His Pa Leave France and Go to Germany, Where They Buy
an Airship—They Get the Airship Safely Landed—Pa and the Boy With
the Airship Start for South Africa—Pa Shows the Men What Power He
Has Over the Animal Kingdom 157

CHAPTER XII.
All Kinds of Climates in South Africa—Pa Hires Men to Capture Wild
Animals—The Boy and His Pa Capture Some Tigers and a Big Lion—
They Have a Narrow Escape from a Rhinoceros 170
CHAPTER XIII.
Pa Was a Hero After Capturing Two Tigers and a Lion—Pa Had an Old
Negro With Sixty Wives Working for Him—Pa Makes His Escape in
Safety—Pa Goes to Catch Hippopotamusses 181

CHAPTER XIV.
Pa Was Blackmailed and Scared Out of Lots of Money—Pa Teaching the
Natives to Speak English—Pa Said the Natives Acted Like Human
Beings—Pa Buys Some Animals in the Jungle 194

CHAPTER XV.
The Idea of Airships is All Right in Theory, but They are Never Going to Be
a Reliable Success—Pa Drowns the Lions Out With Gas—The Bad Boy
and His Pa Capture a Couple of Lions—Pa Moves Camp to Hunt Gorillas 207

CHAPTER XVI.
The Boy’s Pa Shows Bravery in the Jungles in Africa—Four Gorillas Chase
Pa—The Boy and His Pa Don’t Sleep Much at Night—The Boy
Discovers a Marsh Full of Wild Buffaloes 220

CHAPTER XVII.
The Boy’s Experience With an African Buffalo—The Boy’s Pa Shoots
Roman Candles to Scare the Buffaloes—The Boy’s Pa Tames the Wild
Animals 234

CHAPTER XVIII.
The Boy and His Pa Start for the Coast in an Airship—Pa Saluted the
Crowd as We Passed Over Them—The Airship Lands Amid a Savage
Tribe—The King of the Tribe Escorts Pa and the Boy to the Palace 246

CHAPTER XIX.
The Boy’s Pa Becomes King over the Negroes—Pa Shows the Natives
How to Dig Wells—Pa Teaches the Natives to become Soldiers—The
Boy Uses a Dozen Nigger Chasers and Some Roman Candles—The
Boy, His Pa and the Natives Assist at the 4th of July Celebration 258
ILLUSTRATIONS.

Gee, My Ideas of an Orphan Home Got a Shock.


The Way Freshmen Do in College When They’re Being
Murdered.
Gosh, But I Never Had Such an Excursion.
Grabbed the Balloon Rope and Gave it a Hitch Around the
Pole.
Any Man That Lays Hands on the Government Mail Can
Be Imprisoned for Life for Treason.
Hit the Chief of Police With a Bottle.
They Pulled Me Through the Forty-Foot Gun to Swab it
Out.
When it Exploded the Jap Was the Scaredest Person I
Ever Saw.
The Boss of the Boat Ordered Me Pulled Out With a Boat
Hook.
I Am Thy Father’s Ghost—Come on in, the Water’s Fine.
The Captain Got Upon a Chair and Pulled a Revolver and
Was Going to Shoot.
I Gave Him a Squeeze That Sent a Shock Through Him
That Loosened His Teeth.
Pa’s Face Was Scratched So They Sent Him to the Pest
House.
After Pa Had Been Ducked in the Fountain They Charged
for Two Ducks He Killed by Falling on Them.
The Fireworks Went Off. The Woman Threw a Fit and Pa
Raised Out of the Smoke.
Up She Went With the Inventor Steering and Pa Hanging
on for Dear Life.
Pa Gave a Honk Honk Like an Auto, But the Lion Wasn’t
Frightened So You Would Notice.
When Pa Found the Snake Coiled Up on His Blanket He
Threw a Fit.
Looking Him Square in the Face I began to Chant, Ene-
Mene-Miny-Mo.
Pa Astride of a Zebra, Has Frightened the Elephants Into a
Stampede by Playing “A Hot Time” on a Mouth Organ.
Pa Made a Lunge and Fell on Top of the Little Elephant,
Which Began to Make a Noise Like a Baby.
“There’s Your Lions, About a Dozen, Captured Down in
That Hole; Help Yourselves,” Said Pa.
“Get in There, You Measly Cur Dog,” Said Pa, Kicking the
Big Lion at Every Jump.
Pa Stopped the Music and Repeated an Old Democratic
Speech of His, and They Acted Just Like a Caucus.
All He Had to Do Was Play “Supper is Now Ready in the
Dining Car.”
Some of Those Negroes are Running Yet, and Will, No
Doubt, Come Out at Cairo, Egypt.
Pa Had to Put His Foot on Their Necks and Acknowledge
Him Their King and Protector.
Peck’s Bad Boy in an Airship.
CHAPTER I.
The Bad Boy Wants to Be an Orphan—The Bad Boy Goes to an
Orphan Asylum—The Government Gives the Bad Boy’s Pa an
Appointment to Travel Over the World and Get Information About
Airships, Dirigible Balloons and Everything to Help Our Government
Know What Other Governments Are Doing in Case of War.

I have always wanted to be an orphan and I guess now I have got


my wish.
I have watched orphans a whole lot and they have seemed to me to
have the easiest job outside of politics.
To see a good mess of orphans at an Orphan Asylum, with no
parents to butt in and interfere with your enjoyment has seemed to
me to be an ideal existence.
When a boy has a father that he has to watch constantly to keep him
from going wrong he has no time to have any fun, but to belong to a
syndicate of orphans, with an easy old maid matron to look after the
whole bunch, an individual orphan who has ginger in him can have
the time of his young life. At least that is the way it has always
seemed to me.
They set on the food at an orphanage, and if you have a pretty good
reach, you can get enough corralled around your plate to keep the
wolf from the door, and when it comes to clothes, you don’t have to
go to a tailor, or a hand me down store, and take something you
don’t want because it is cheap, but you take any clothes that are
sent in by charitable people, which have been worn enough so there
is no style about them, and no newness to wear off by rolling in the
grass, and you put them on and let it go at that, if they do smell of
moth balls.
Pa has skipped and I am left alone and I shall enter as a freshman in
an Orphan Asylum, and later go out into the world and travel on my
shape.
Pa took me to Washington and for a week he was visiting the
different Departments, and nights he would talk in his sleep about air
ships and balloons, and forts and battleships, and about going
abroad, until I thought he was getting nutty.
One day he called me up to our room in the hotel and after locking
the door, and plugging up the keyhole with chewed paper he said:
“Now, Hennery, I want you to listen right out loud. The government
has given me an appointment to travel over the world and get
information about air ships, divagable balloons, and everything that
will help our government to know what other governments are doing
in inventing things to be used in case of war. I am to be the Billy
Pinkerton of the War Department and shall have to spy in other
governments, and I am to be the traveling diplomat of the
government, and jolly all nations, and find out how things are running
everywhere.
“You will have to stay home this time because you would be a dead
give away, so I will send you to a nice orphan home where you will
be taught to work, and where guards will keep you on the inside of
the fence, and put you to bed in a straight jacket if you play any of
your jokes, see?” and Pa gave me a ticket to an orphans’ home, and
a letter of introduction to the matron and the next day I was an
inmate, with all the degrees coming to me. What do you think of that,
and Pa on the ocean, with a government commission in his pocket?
Gee, but my ideas of an orphans’ home got a shock when I arrived
at the station where the orphans’ home was located. I thought there
would be a carriage at the train to meet me, and a nice lady dressed
in white with a cap on her head, to take me in her arms and hug me,
and say, “Poor little boy, I will be a sister to you,” but there was no
reception committee, and I had to walk a mile with my telescope
valise, and when I found the place and went in the door, to present
my letter to the matron, a man with a scar on his face, and one eye
gone, met me and looked over my papers, and went, one eye on me,
and called an assistant private and told him to take me and give me
the first or entered apprentice degree.

Gee, My Ideas of an Orphan Home Got a Shock.

The private took me by the wrist and gave me a jerk and landed me
in the laundry, and told me to strip off, and when I had removed my
clothes and folded them and laid them on a table, he took the clothes
away from me, and then told me to climb into a laundry tub, and he
turned cold water on me and gave me a bar of yellow laundry soap,
and after I had lathered myself he took a scrubbing brush, such as
floors are scrubbed with, and proceeded in one full swoop to peel the
hide off of me with a rough crash towel till you could see my veins
and arteries, and inside works as well as though you had used X-
rays, and when I was ready to die and wanted to, I yelled murder,
and he put his hand over my mouth so hard that he loosened my
front teeth, and I guess I died right there or fainted, for when I came
to, and thought the resurrection morning, that they used to tell me
about in the Sunday School, had come. I found myself dressed in a
sort of combination shirt and drawers, like a bunny nightie, made of
old saddle blankets, and he told me that was the uniform of the
orphanage and that I could go out and play for fifteen minutes, after
which the bell would ring and I could go from play to work. Gosh, but
I was glad to get out doors, but when I began to breathe the fresh air,
and scratch myself where the saddle blanket clothes pricked me,
about fifty boys, who were evidently sophomores in the orphanage,
came along, and made a rush for me, to haze me as a freshman.
Well, they didn’t do a thing to me. They tied a rope around one
ankle, and threw the rope over a limb, and pulled me off the ground,
and danced a war dance around me and run thistles up my trouser’s
legs, and spanked me with a board with slivers in it, and let me down
and walked over me in a procession, singing “There’ll be a hot time
in the old town to-night.” I laughed all the time, because that is the
way freshmen do in college when they are being murdered, and I
thought my new associates would like me better if I died game. Just
before I died game the bell rang, and the one eyed pirate and his
chief of staff came out and said we would go to work, and the boys
were divided into squads and put to work, some husking corn, others
sweeping up dead leaves, others milking cows, and doing everything
necessary around a farm.
Before I was set to work I had a few minutes of silent reflection, and I
thought of my changed condition from my porcelain lined bath tub
with warm water and soft towels, to that bath in the laundry, and the
skinning process of preparing a boy for a better life.

The Way Freshmen Do in College When They’re Being


Murdered.

Then what do you suppose they set me to work at? Skinning bull
heads and taking out the insides. It seems the boys catch bull heads
in a pond, and the bull heads are used for human food, and the
freshest boys were to dress them. Well, I wasn’t going to kick on
anything they gave me for a stunt, so I put on an apron, and for four
hours I skinned and cut open bull heads in a crude sort of way, until I
was so sick I couldn’t protect myself from the assaults of the live bull
heads, and the cook said I done the job so well that she would ask to

You might also like