93 Goals: Breaking Wayne Gretzky’s 92-Goal Single Season Record

In the 1981–82 National Hockey League (NHL) season, Wayne Gretzky set the record for most goals in a single season with 92 goals in just 80 games for the Edmonton Oilers. The only player to ever come close to Gretzky’s goal record was Brett Hull in the 1990–91 season, when he put up 86 goals in just 78 games for the St. Louis Blues. Since then, no player has broken 80 goals, and only two players in the last 20 years have scored more than 60 in a season (Alexander Ovechkin ’08 and Steven Stamkos ‘12). The 92-goal record is just one of the NHL records held by Wayne Gretzy that many believe will never be broken. In this article, I will approximate the odds of beating Gretzky’s 92-goal record using a Monte Carlo analysis. I analyze the greatest goal scoring seasons in the modern era to test how lucky a player would have to be to break 92 goals.


NHL Goal Scoring History

First, some background on Gretzky’s 92-goal record and why it has never been broken. As stated above, in the 1981–82 season Gretzky set the NHL single season scoring record that has now lasted for 38 years. This is not purely due to the skill of ‘The Great One’ but also due to the different style of hockey played back then. See below for a graph of average goals scored per game in the NHL, data is from Hockey-Reference.com.

Image for post

The 1970s-1990s saw a large increase in goals scored per game. Rapid expansion of the NHL combined with higher skill players led to more goals scored in a single game. The late 80s and 90s brought with them better goaltending, better coaching, better players from around the globe, and a range of other factors that all decreased the number of goals scored per game¹. An often asked question is, “How much of an effect did Gretzky have on the average goals scored per game during his career?”. See below for a graph showing the average goals scored per game excluding goals and assists from Gretzky’s career.

Image for post

Since the 1980s, the game of hockey has changed astronomically. The average number of goals scored per game has dropped from around 8 to 6, and the number of 50-goal seasons has also dropped. Between the 1979–80 season and the 1989–1990 season NHL players achieved a total of eighty-four 50-goal seasons². Now, between the 2009–10 and 2019–20 seasons there were just 11³. As a result of increased player skill, better coaching, and technological advances in equipment, modern-era goal scoring is down both league-wide and for individual players. Could any player in the modern era break Gretzky’s 92-goal season? Let’s find out.

#hockey #sports #nhl #statistics #data-science #data analysis

What is GEEK

Buddha Community

93 Goals: Breaking Wayne Gretzky’s 92-Goal Single Season Record
Mike  Kozey

Mike Kozey

1656151740

Test_cov_console: Flutter Console Coverage Test

Flutter Console Coverage Test

This small dart tools is used to generate Flutter Coverage Test report to console

How to install

Add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dev_dependencies:
  test_cov_console: ^0.2.2

How to run

run the following command to make sure all flutter library is up-to-date

flutter pub get
Running "flutter pub get" in coverage...                            0.5s

run the following command to generate lcov.info on coverage directory

flutter test --coverage
00:02 +1: All tests passed!

run the tool to generate report from lcov.info

flutter pub run test_cov_console
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
 print_cov_constants.dart                    |    0.00 |    0.00 |    0.00 |    no unit testing|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

Optional parameter

If not given a FILE, "coverage/lcov.info" will be used.
-f, --file=<FILE>                      The target lcov.info file to be reported
-e, --exclude=<STRING1,STRING2,...>    A list of contains string for files without unit testing
                                       to be excluded from report
-l, --line                             It will print Lines & Uncovered Lines only
                                       Branch & Functions coverage percentage will not be printed
-i, --ignore                           It will not print any file without unit testing
-m, --multi                            Report from multiple lcov.info files
-c, --csv                              Output to CSV file
-o, --output=<CSV-FILE>                Full path of output CSV file
                                       If not given, "coverage/test_cov_console.csv" will be used
-t, --total                            Print only the total coverage
                                       Note: it will ignore all other option (if any), except -m
-p, --pass=<MINIMUM>                   Print only the whether total coverage is passed MINIMUM value or not
                                       If the value >= MINIMUM, it will print PASSED, otherwise FAILED
                                       Note: it will ignore all other option (if any), except -m
-h, --help                             Show this help

example run the tool with parameters

flutter pub run test_cov_console --file=coverage/lcov.info --exclude=_constants,_mock
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

report for multiple lcov.info files (-m, --multi)

It support to run for multiple lcov.info files with the followings directory structures:
1. No root module
<root>/<module_a>
<root>/<module_a>/coverage/lcov.info
<root>/<module_a>/lib/src
<root>/<module_b>
<root>/<module_b>/coverage/lcov.info
<root>/<module_b>/lib/src
...
2. With root module
<root>/coverage/lcov.info
<root>/lib/src
<root>/<module_a>
<root>/<module_a>/coverage/lcov.info
<root>/<module_a>/lib/src
<root>/<module_b>
<root>/<module_b>/coverage/lcov.info
<root>/<module_b>/lib/src
...
You must run test_cov_console on <root> dir, and the report would be grouped by module, here is
the sample output for directory structure 'with root module':
flutter pub run test_cov_console --file=coverage/lcov.info --exclude=_constants,_mock --multi
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|
---------------------------------------------|---------|---------|---------|-------------------|
File - module_a -                            |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|
---------------------------------------------|---------|---------|---------|-------------------|
File - module_b -                            |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

Output to CSV file (-c, --csv, -o, --output)

flutter pub run test_cov_console -c --output=coverage/test_coverage.csv

#### sample CSV output file:
File,% Branch,% Funcs,% Lines,Uncovered Line #s
lib/,,,,
test_cov_console.dart,0.00,0.00,0.00,no unit testing
lib/src/,,,,
parser.dart,100.00,100.00,97.22,"97"
parser_constants.dart,100.00,100.00,100.00,""
print_cov.dart,100.00,100.00,82.91,"29,49,51,52,171,174,177,180,183,184,185,186,187,188,279,324,325,387,388,389,390,391,392,393,394,395,398"
print_cov_constants.dart,0.00,0.00,0.00,no unit testing
All files with unit testing,100.00,100.00,86.07,""

Installing

Use this package as an executable

Install it

You can install the package from the command line:

dart pub global activate test_cov_console

Use it

The package has the following executables:

$ test_cov_console

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add test_cov_console

With Flutter:

 $ flutter pub add test_cov_console

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  test_cov_console: ^0.2.2

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:test_cov_console/test_cov_console.dart';

example/lib/main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Author: DigitalKatalis
Source Code: https://github.com/DigitalKatalis/test_cov_console 
License: BSD-3-Clause license

#flutter #dart #test 

93 Goals: Breaking Wayne Gretzky’s 92-Goal Single Season Record

In the 1981–82 National Hockey League (NHL) season, Wayne Gretzky set the record for most goals in a single season with 92 goals in just 80 games for the Edmonton Oilers. The only player to ever come close to Gretzky’s goal record was Brett Hull in the 1990–91 season, when he put up 86 goals in just 78 games for the St. Louis Blues. Since then, no player has broken 80 goals, and only two players in the last 20 years have scored more than 60 in a season (Alexander Ovechkin ’08 and Steven Stamkos ‘12). The 92-goal record is just one of the NHL records held by Wayne Gretzy that many believe will never be broken. In this article, I will approximate the odds of beating Gretzky’s 92-goal record using a Monte Carlo analysis. I analyze the greatest goal scoring seasons in the modern era to test how lucky a player would have to be to break 92 goals.


NHL Goal Scoring History

First, some background on Gretzky’s 92-goal record and why it has never been broken. As stated above, in the 1981–82 season Gretzky set the NHL single season scoring record that has now lasted for 38 years. This is not purely due to the skill of ‘The Great One’ but also due to the different style of hockey played back then. See below for a graph of average goals scored per game in the NHL, data is from Hockey-Reference.com.

Image for post

The 1970s-1990s saw a large increase in goals scored per game. Rapid expansion of the NHL combined with higher skill players led to more goals scored in a single game. The late 80s and 90s brought with them better goaltending, better coaching, better players from around the globe, and a range of other factors that all decreased the number of goals scored per game¹. An often asked question is, “How much of an effect did Gretzky have on the average goals scored per game during his career?”. See below for a graph showing the average goals scored per game excluding goals and assists from Gretzky’s career.

Image for post

Since the 1980s, the game of hockey has changed astronomically. The average number of goals scored per game has dropped from around 8 to 6, and the number of 50-goal seasons has also dropped. Between the 1979–80 season and the 1989–1990 season NHL players achieved a total of eighty-four 50-goal seasons². Now, between the 2009–10 and 2019–20 seasons there were just 11³. As a result of increased player skill, better coaching, and technological advances in equipment, modern-era goal scoring is down both league-wide and for individual players. Could any player in the modern era break Gretzky’s 92-goal season? Let’s find out.

#hockey #sports #nhl #statistics #data-science #data analysis

Bhakti Rane

1625057623

Click2Undo - 1 Click App to restore Dynamics 365 CRM data to its last known state

Undo changes & restore records in Dynamics 365 CRM with a single click

Click2Undo is a productivity app that helps you to undo changes in the data in Dynamics 365 CRM with a single click. Be it the last change that you’d want to restore, or the changes that were done in the past which you would like to get back, Click2Undo can do it without any hassle. This provides a safety net within which users can conduct day-to-day activities without fear of losing data due to human or technical errors.
Click2Undo is available for Dynamics CRM 8.2 and above, Dataverse (Power Apps). It supports deployment models - On-Premises and Online.
Features
• Entity Support: Click2Undo provides support to all OOB as well as Custom Entities
• Undo Last Changes: Ability to restore the last changes done to a Dynamics 365 CRM record by clicking the Click2Undo button
• Undo Past Changes: Ability to undo past changes made to multiple fields on Dynamics 365 CRM records in one go using History button
• Undo Bulk Changes: Ability to undo changes on multiple records at one go.

#restore last state of dynamics 365 records #restoring deleted dynamics 365 records #recovering deleted dynamics 365 records #recover deleted dynamics crm records #dynamics 365 online recover deleted records #restore records dynamics crm

Simpliv LLC

Simpliv LLC

1582886905

Career Goal Mapping Course | The Beginner's Guide to Goal Setting | Simpliv

Description
So, here we are again another year, another opportunity to DO more, BE more, HAVE more but lets look back at last year (and the year before, and the year before that) did you or have you managed to achieve any of the goals on your list? Do you even MAKE “lists”, or do you just kind of wait for “life” to happen to you? Has it been ‘happening’ to you in the way that you want?

This course is for all of those people out there who want to make a CHANGE this year! OR who want to make a difference!! Now, ALTHOUGH I keep saying ‘this year’ - this is because this course was created on 1st Jan 2017 but your ‘year’ can begin at any time. 1st June, 1st September, on your birthday it doesn’t really matter. All that matters, is that you MARK THIS DAY as the day that you turned your life around and everything started to look up!

Am I a motivation coach and speaker? No. Am I here to tell you how rubbish you are and to promise that I have the answer to all of life’s mysteries and ills? No. I am simply someone, who believes that LIFE is about CHOICES. We all have 24 hours in a day, and how we choose to SPEND those hours, minutes, seconds is how we came to be in the position that we are in today maybe it was deliberate, or maybe you’ve kind of just wandered and floated up unto this point. What I can assure you, is that this course is all about the science / art of intention and of DELIBERATE CREATION. Together, you and I are going to create the PLAN for the next 12 months ahead. And then I’m going to show you how you break this plan down, right into day-to-day actions, that will take you in the direction that you want to go in.

No more wandering about. No more pontificating. No more pro-procrastinating! No more ‘thinking’ this is all about Doing. Have you ever looked at someone and been envious? I want their life! How to they do that? What are they DOING that I’m not?? Could it be that they have a master plan, that they’re following? Could it be that they have tuned into what they want, and set about going to get it? I remember when I was 16, and one of the first waitiressing jobs I had was with a company called Peoples Network UK. The lady who ran it (Rita) said to me “You have to grab life by the balls Lisa, and shake it for all its got!!!” About 1 month later, she was dead. Tragic drink-driving car accident. But those words never left me. All you’ve got to do it just GRAB LIFE by the balls!!! And I’m proud to say, almost 20 years later. I’m doing just that!

The methodology I’m about to lay out to you was the reason for 2015 being ‘the year of travel’. I went to around 10 countries that year. I set the intention and off I went. 2016 was the year of completion - financial results. This year 2018, will be the year of relationships. Just watch this space. 2018 is numerologically a year of relationships 2 + 0 + 1 + 8 = 11 = 1 + 1 = 2. Look up life path number 2. So, I invite you, my friend and student, to join me on a journey, whereby together, we reflect, and then we set the intention - and make the next 12 months your most successful EVER!

Note - when your life starts to change and everyone wonders what happened to you?? Please share this course with them! Thank-you in advance!

This is not new-age science or mysticism. This is solid, tangible, measureable life-changing material, which you can use over and over again, to get the results you want, and not just dream about.

Who is the target audience?

Progressive people, self-starters, those who want to get somewhere in life - achievers!
Basic knowledge
Student will need a glass of red wine and a nice quiet place for 3-4 hours to seriously think about their life - and where they want it to go
What will you learn
Create and manifest the best ever year of their life - a process they’ll be able to repeat at intervals (annually, monthly, seasonally), and just create the life they know, want and deserve!

ENROLL

#Top Goal Setting Courses Online #Online Goal Setting Classes #Certified Goal Mapping Coach Programme #Goal Setting online short course

Rust  Language

Rust Language

1640144506

Strings - The Rust Programming Language

Rust For Beginners Tutorial - Strings

In this video we're taking a look at the String, &String and &str types in Rust!

Exercise solutions: https://github.com/PascalPrecht/rustlings/commits/solutions 

---
0:00 Intro
0:09 Exercise 1
4:47 Exercise 2
10:38 Outro


Strings

There are two types of strings in Rust: String and &str.

A String is stored as a vector of bytes (Vec<u8>), but guaranteed to always be a valid UTF-8 sequence. String is heap allocated, growable and not null terminated.

&str is a slice (&[u8]) that always points to a valid UTF-8 sequence, and can be used to view into a String, just like &[T] is a view into Vec<T>.

fn main() {
    // (all the type annotations are superfluous)
    // A reference to a string allocated in read only memory
    let pangram: &'static str = "the quick brown fox jumps over the lazy dog";
    println!("Pangram: {}", pangram);

    // Iterate over words in reverse, no new string is allocated
    println!("Words in reverse");
    for word in pangram.split_whitespace().rev() {
        println!("> {}", word);
    }

    // Copy chars into a vector, sort and remove duplicates
    let mut chars: Vec<char> = pangram.chars().collect();
    chars.sort();
    chars.dedup();

    // Create an empty and growable `String`
    let mut string = String::new();
    for c in chars {
        // Insert a char at the end of string
        string.push(c);
        // Insert a string at the end of string
        string.push_str(", ");
    }

    // The trimmed string is a slice to the original string, hence no new
    // allocation is performed
    let chars_to_trim: &[char] = &[' ', ','];
    let trimmed_str: &str = string.trim_matches(chars_to_trim);
    println!("Used characters: {}", trimmed_str);

    // Heap allocate a string
    let alice = String::from("I like dogs");
    // Allocate new memory and store the modified string there
    let bob: String = alice.replace("dog", "cat");

    println!("Alice says: {}", alice);
    println!("Bob says: {}", bob);
}

More str/String methods can be found under the std::str and std::string modules

Literals and escapes

There are multiple ways to write string literals with special characters in them. All result in a similar &str so it's best to use the form that is the most convenient to write. Similarly there are multiple ways to write byte string literals, which all result in &[u8; N].

Generally special characters are escaped with a backslash character: \. This way you can add any character to your string, even unprintable ones and ones that you don't know how to type. If you want a literal backslash, escape it with another one: \\

String or character literal delimiters occuring within a literal must be escaped: "\"", '\''.

fn main() {
    // You can use escapes to write bytes by their hexadecimal values...
    let byte_escape = "I'm writing \x52\x75\x73\x74!";
    println!("What are you doing\x3F (\\x3F means ?) {}", byte_escape);

    // ...or Unicode code points.
    let unicode_codepoint = "\u{211D}";
    let character_name = "\"DOUBLE-STRUCK CAPITAL R\"";

    println!("Unicode character {} (U+211D) is called {}",
                unicode_codepoint, character_name );


    let long_string = "String literals
                        can span multiple lines.
                        The linebreak and indentation here ->\
                        <- can be escaped too!";
    println!("{}", long_string);
}

Sometimes there are just too many characters that need to be escaped or it's just much more convenient to write a string out as-is. This is where raw string literals come into play.

fn main() {
    let raw_str = r"Escapes don't work here: \x3F \u{211D}";
    println!("{}", raw_str);

    // If you need quotes in a raw string, add a pair of #s
    let quotes = r#"And then I said: "There is no escape!""#;
    println!("{}", quotes);

    // If you need "# in your string, just use more #s in the delimiter.
    // There is no limit for the number of #s you can use.
    let longer_delimiter = r###"A string with "# in it. And even "##!"###;
    println!("{}", longer_delimiter);
}

Want a string that's not UTF-8? (Remember, str and String must be valid UTF-8). Or maybe you want an array of bytes that's mostly text? Byte strings to the rescue!

use std::str;

fn main() {
    // Note that this is not actually a `&str`
    let bytestring: &[u8; 21] = b"this is a byte string";

    // Byte arrays don't have the `Display` trait, so printing them is a bit limited
    println!("A byte string: {:?}", bytestring);

    // Byte strings can have byte escapes...
    let escaped = b"\x52\x75\x73\x74 as bytes";
    // ...but no unicode escapes
    // let escaped = b"\u{211D} is not allowed";
    println!("Some escaped bytes: {:?}", escaped);


    // Raw byte strings work just like raw strings
    let raw_bytestring = br"\u{211D} is not escaped here";
    println!("{:?}", raw_bytestring);

    // Converting a byte array to `str` can fail
    if let Ok(my_str) = str::from_utf8(raw_bytestring) {
        println!("And the same as text: '{}'", my_str);
    }

    let _quotes = br#"You can also use "fancier" formatting, \
                    like with normal raw strings"#;

    // Byte strings don't have to be UTF-8
    let shift_jis = b"\x82\xe6\x82\xa8\x82\xb1\x82\xbb"; // "ようこそ" in SHIFT-JIS

    // But then they can't always be converted to `str`
    match str::from_utf8(shift_jis) {
        Ok(my_str) => println!("Conversion successful: '{}'", my_str),
        Err(e) => println!("Conversion failed: {:?}", e),
    };
}

For conversions between character encodings check out the encoding crate.

A more detailed listing of the ways to write string literals and escape characters is given in the 'Tokens' chapter of the Rust Reference.

#rust #programming #developer