-
String:
A growable, heap-allocated string type. It's the most common string type used in Rust and is often used when you need to modify the string's contents. -
&str:
A string slice, which is a reference to a portion of a string, usually a part of aStringor a string literal. It is an immutable reference to a sequence of UTF-8 encoded bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// A module for emitting [`Event`] defined in this module by internally looping events and handling crossterm events | |
| use crossterm::event::{Event as CrosstermEvent, EventStream as CrosstermEventStream}; | |
| use pin_project::pin_project; | |
| use std::time::Duration; | |
| use tokio::sync::mpsc; | |
| use tokio_stream::{Stream, StreamExt}; | |
| #[derive(Debug, Clone, Copy)] | |
| pub enum Event { | |
| Tick, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use clap::{Parser, ValueEnum}; | |
| use glob::{glob, GlobError, PatternError}; | |
| use std::path::PathBuf; | |
| use thiserror::Error; | |
| #[derive(Debug, clap::Parser)] | |
| struct Args { | |
| #[arg(help = "Target files path")] | |
| files: Vec<String>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "progressbar_example/progress" | |
| "time" | |
| ) | |
| func main() { | |
| count := 10000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use eyre::{Result, WrapErr}; | |
| use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufWriter}; | |
| use tokio::process::Command; // Use eyre for error handling | |
| pub async fn run_command<W: tokio::io::AsyncWrite + Send + 'static + Unpin>( | |
| cmd: &str, | |
| args: &[&str], | |
| stdout_writer: W, | |
| stderr_writer: W, | |
| ) -> Result<()> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use eyre::OptionExt; | |
| use reqwest::Url; | |
| use select::{ | |
| document::Document, | |
| predicate::{Class, Name, Predicate}, | |
| }; | |
| use serde::{Deserialize, Serialize}; | |
| #[derive(Debug, Serialize, Deserialize, Default)] | |
| pub struct DiffInfo { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use clap::{Parser, ValueHint}; | |
| use eyre::WrapErr; | |
| use polars::datatypes::DataType; | |
| use polars::prelude::*; | |
| use sea_query::{Alias, ColumnDef, Iden, SchemaStatementBuilder, Table, TableCreateStatement}; | |
| use std::path::{Path, PathBuf}; | |
| use tokio; | |
| #[derive(clap::Parser, Debug)] | |
| #[command(about = "A command line tool for flexible registration for CSV data to DB tables")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Find Text from JSON</title> | |
| </head> | |
| <body> | |
| <h1>Find Text from JSON</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import "./App.css"; | |
| import LoginBox from "./components/LoginBox"; | |
| import { | |
| createTheme, | |
| CssBaseline, | |
| ThemeProvider, | |
| useMediaQuery, | |
| } from "@mui/material"; | |
| import { deepPurple, indigo } from "@mui/material/colors"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| println!( | |
| "{}", | |
| (["なで", "しこ"]) | |
| .iter() | |
| .flat_map(|&s| std::iter::repeat(s).take(2)) | |
| .collect::<String>(), | |
| ); | |
| } |