blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
bb2b6427c9c7766217a19f88a376bd08a8408e53
Rust
stanciua/adventofcode2017
/day13/src/main.rs
UTF-8
2,382
3.046875
3
[]
no_license
#![feature(inclusive_range_syntax)] #[macro_use] extern crate nom; use std::str; use nom::{digit, space}; use std::fs::File; use std::io::Read; use std::collections::HashMap; named!( depth<i32>, map_res!(map_res!(digit, str::from_utf8), str::parse) ); named!( range<i32>, map_res!(map_res!(digit, str:...
true
3eec24f43a90fb1cede76ffc9b7e8b4f278a39fc
Rust
mcarton/rust-naughty-strings
/src/bin/make-lib.rs
UTF-8
1,149
2.59375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate serde_json; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::process::Command; const NAUGHTY_REPO_URL : &'static str = &"https://github.com/minimaxir/big-list-of-naughty-strings.git"; fn main() { let path = std::env::args().nth(1).unwrap_or(NAUGHTY_REPO_URL.into()); let ...
true
53c1b80aa507a9a52e21ab013ecd82b20ed0a043
Rust
amm834/rustlanguage
/static_dispath/src/main.rs
UTF-8
567
3.6875
4
[]
no_license
trait Duplicateable { fn dupl(&self) -> String; } impl Duplicateable for String { fn dupl(&self) -> String { format!("{}", *self) } } impl Duplicateable for i32 { fn dupl(&self) -> String { format!("{}", *self * 2) } } // static /*fn duplicate<T:Duplicateable>(x:T){ println!("{}"...
true
2812db4840470b35b81968402b0e196a577a7016
Rust
AkifumiSato/at-api
/src/usecase/attendance_records/add.rs
UTF-8
601
2.640625
3
[]
no_license
use crate::database_utils::error::DataAccessError; use crate::domain::entity::attendance_record::AttendanceRecord; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct InputData { pub uid: String, pub start_time: i64, pub end_time: i64, pub break_time: i32, } pub tr...
true
98fe8e1a4baed0f759ba4c701cd9c120f38a7569
Rust
LucioFranco/RustyRaft
/src/server.rs
UTF-8
1,026
2.546875
3
[ "Apache-2.0" ]
permissive
use futures::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::{Future, Stream}; use tokio::net::{TcpListener, TcpStream}; use std::collections::HashMap; use std::net::{SocketAddr, ToSocketAddrs}; use std::sync::{Arc, RwLock}; use connection::Connection; use messages::{Message, MessageType}; pub type S...
true
fda52a2b3efec0a0e80152c81dc8013a97364dd8
Rust
bsundsrud/talkboy
/src/archive/load.rs
UTF-8
3,875
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
#![allow(unreachable_patterns)] use super::convert; use super::{ArchivedRequest, RequestFacts}; use failure::Error; use har::v1_2::*; use har::{Har, Spec}; use hyper::{Method, Uri}; use serde_json; use slog::Logger; use std::fs; use std::fs::File; use std::io::{Error as IoError, ErrorKind, Result as IoResult}; use std:...
true
b60c6ec7065e7e3c4b87ce4067afeea63bb4bd3b
Rust
kerskuchen/Paddles_rs
/game_lib/src/audio.rs
UTF-8
4,588
2.640625
3
[ "MIT", "Unlicense" ]
permissive
use hound; use std; //================================================================================================== // AudioContext //================================================================================================== // // TODO: Set this back to 44100 when we finished the update to SDL2 const AUDI...
true
fa37e421e0b1bec8ce6aa1784663ed8d44fe1ea3
Rust
astro/rad1o-rust
/rad1o-l0dable/src/power.rs
UTF-8
447
2.859375
3
[ "Apache-2.0" ]
permissive
use table::table; /// Wraps millivolts pub struct Voltage(pub u32); impl Voltage { pub fn as_millivolts(&self) -> u32 { self.0 } pub fn as_volts(&self) -> f32 { self.0 as f32 / 1000f32 } } /// Get current battery voltage pub fn get_voltage() -> Voltage { Voltage((table().batteryG...
true
e283b87e306ba5631fbabe09b13c4fce932b1d30
Rust
alekratz/enum-methods
/src/util.rs
UTF-8
1,071
3.4375
3
[ "Apache-2.0" ]
permissive
use std::str; use syn::Ident; pub(crate) fn to_snake_case<S: AsRef<str>>(ident: &S) -> String { let mut snake_case = String::new(); for (i, c) in ident.as_ref().chars().enumerate() { if i > 0 && c.is_uppercase() { snake_case.push('_'); } snake_case.push(c.to_lowercase().ne...
true
aba4bc4d5e3ce28983e5d7da4629147847a6619a
Rust
sigmaSd/forcerun
/src/main.rs
UTF-8
3,943
3
3
[ "MIT" ]
permissive
use std::fs::DirEntry; use std::path::{Path, PathBuf}; const FORCE_RUN_PATH: &str = "/tmp/forcerun"; const ROOT_LIB: &str = "/usr/lib"; fn main() { let exe = std::env::args().nth(1).expect("No binary specified"); let path = prepare_path(&exe); let libs_deps = ldd(&exe); let missing = missing_libs(&lib...
true
d42fd73b8b5be93dc94ca303c437d22e0aefa8d9
Rust
awelkie/rustfst
/rustfst/src/algorithms/condense.rs
UTF-8
1,897
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::algorithms::visitors::SccVisitor; use crate::fst_traits::{ExpandedFst, Fst, MutableFst}; use crate::algorithms::arc_filters::AnyArcFilter; use crate::algorithms::dfs_visit::dfs_visit; use crate::semirings::Semiring; use anyhow::Result; // Returns an acyclic FST where each SCC in the input FST has been cond...
true
dd9922a29170e295367d73a545363b4a07b704ed
Rust
efancier-cn/embedded-gui
/src/geometry/mod.rs
UTF-8
2,562
3.109375
3
[]
no_license
use core::ops::{Add, AddAssign, Neg, Sub}; pub mod axis_order; pub mod measurement; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Position { pub x: i32, pub y: i32, } impl Add<Position> for Position { type Output = Position; fn add(self, rhs: Position) -> Self::Output { Position { ...
true
c246e5bc2cc18381ab55f45c5b5192d28c59b60a
Rust
HarrisonMc555/exercism
/rust/rna-transcription/src/lib.rs
UTF-8
1,685
3.40625
3
[]
no_license
#[derive(Debug, PartialEq)] enum DnaNuc { G, C, T, A, } #[derive(Debug, PartialEq)] enum RnaNuc { C, G, A, U, } #[derive(Debug, PartialEq)] pub struct DNA { nucleotides: Vec<DnaNuc>, } #[derive(Debug, PartialEq)] pub struct RNA { nucleotides: Vec<RnaNuc>, } impl DNA { pub...
true
ee76b9b1f8e3810a8082132d027fe840299eb420
Rust
gltf-rs/gltf
/gltf-json/src/camera.rs
UTF-8
5,612
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::validation::{Checked, Error, Validate}; use crate::{extensions, Extras, Path, Root}; use gltf_derive::Validate; use serde::{de, ser}; use serde_derive::{Deserialize, Serialize}; use std::fmt; /// All valid camera types. pub const VALID_CAMERA_TYPES: &[&str] = &["perspective", "orthographic"]; /// Specifies...
true
4564f2fa8a37ad527915112fe96347ecfc0eb278
Rust
AndrewPlayer3/AdventOfCode
/rust/day1/day_one.rs
UTF-8
202
2.796875
3
[]
no_license
use std::env; use std::fs; fn main() { let contents = fs::read_to_string("input.txt") .expect("Something went wrong opening the file"); println!("With text:\n{}", contents); }
true
7dd625b2c8b066742b0d57b1e85d0c7a67ae4174
Rust
Techno-coder/example_os
/kernel/src/tests/display/text_mode/display_facade.rs
UTF-8
946
3.140625
3
[ "MIT" ]
permissive
use display::text_mode::*; use spin::Mutex; pub struct DisplayFacade<'a, D: 'a> { display: &'a Mutex<D>, } impl<'a, D: TextDisplay> DisplayFacade<'a, D> { pub fn new(display: &'a Mutex<D>) -> DisplayFacade<'a, D> { DisplayFacade { display, } } } impl<'a, D: TextDisplay> TextDisplay for DisplayFacade<'a, D>...
true
b008d6ba5b94cd4514313c04dc9db13f7e1292c0
Rust
AJTJ/rust_practice
/strings/src/main.rs
UTF-8
1,672
3.390625
3
[]
no_license
fn main() { // creates an empty string, to load data into let mut my_string = String::new(); // applying the to_string method on a string literal my_string = "initial content".to_string(); // this is equivalent to the following // my_string = String::from("initial content"); println!("my_s...
true
b95351418272d6de9e76935bba6123ff576c708a
Rust
qarmin/GodotDemoProjectCICreator
/src/main.rs
UTF-8
6,990
2.546875
3
[]
no_license
use std::fs::{File, Metadata}; use std::io::Write; use std::path::Path; use std::{env, fs, process}; fn main() { let all_arguments: Vec<String> = env::args().collect(); if all_arguments.len() < 2 { println!("You must provide absolute path to Godot project."); process::exit(1); } let god...
true
319f4a40c42a464996e2e408499306a3f1868314
Rust
rustysoft/github-client
/src/client/pull_request.rs
UTF-8
4,381
2.609375
3
[ "MIT" ]
permissive
use super::{GenericResponse, Result, BASE_URL}; use crate::payload::{PullRequestCommitPayload, PullRequestPayload, SearchPayload}; use reqwest::Client; pub struct PullRequestClient<'a> { pub(super) client: &'a Client, } impl<'a> PullRequestClient<'a> { pub fn create(&self, repository_name: &str, body: String)...
true
58c5e788d20c699b0fed166f10a04c418e28ddbd
Rust
randomPoison/online-fps
/client/src/systems/player_pitch.rs
UTF-8
560
2.609375
3
[]
no_license
use amethyst::{core::Transform, ecs::prelude::*}; use components::*; #[derive(Debug, Default)] pub struct PlayerPitchSystem; #[derive(SystemData)] pub struct Data<'a> { pitch: ReadStorage<'a, PlayerPitch>, transform: WriteStorage<'a, Transform>, } impl<'a> System<'a> for PlayerPitchSystem { type SystemDa...
true
870296a052bb156e1d00b6aef0527bc5b53ec2d0
Rust
VenmoTools/OperatingSystem
/uefis/src/elf/elf64.rs
UTF-8
7,188
2.6875
3
[ "Apache-2.0" ]
permissive
use core::fmt; use crate::elf::{ABIVersion, ElfHeaderFlags, ElfVersion, GenElf, GenElfHeader, GenProgramHeader, GenSectionHeader}; use crate::elf::elf_type::{ABI, ElfEndian, ElfKind, ElfMachine, ElfType, ProgramFlags, ProgramType, SectionType}; use crate::elf::flags::SectionHeaderFlags; pub struct Elf64<'a>(&'a [u8])...
true
456b43c03dd039f499311f577f72f810127e3759
Rust
skrap/rusted_cart
/src/main.rs
UTF-8
11,963
2.734375
3
[]
no_license
use lazy_static; use permutator::Combination; use serde::Deserialize; use std::collections::{BTreeSet, HashMap, VecDeque}; use std::error::Error; fn mushes() -> Result<Vec<Mush>, Box<Error>> { let f = std::fs::File::open("assets/agaricus-lepiota.data")?; let mut rdr = csv::ReaderBuilder::new().has_headers(fals...
true
bc38a6d8c5aebdf1fe5ee4640d6c05b4ed4b736f
Rust
moroso/compiler
/src/ir/inliner.rs
UTF-8
12,498
2.609375
3
[]
no_license
use ir::{Op, OpNode, VarName, RValueElem}; use mc::ast::{UnOpNode, CanHaveId}; use mas::ast::{InstNode, JumpTarget}; use std::collections::{BTreeSet, BTreeMap}; pub struct Inliner; fn renumber_label(label: usize, label_map: &mut BTreeMap<usize, usize>, label_id: &mut usize) -> usize { *label_map.entry(label).or_...
true
578b36885dcbeeb9083b4e17a1e0a415b3c92d6a
Rust
sybila/biodivine-aeon-server
/src/scc/algo_stability_analysis/mod.rs
UTF-8
2,256
2.84375
3
[ "MIT" ]
permissive
use biodivine_lib_param_bn::symbolic_async_graph::{ GraphColoredVertices, GraphColors, SymbolicAsyncGraph, }; use biodivine_lib_param_bn::VariableId; use std::collections::HashMap; mod _impl_attractor_stability_data; mod _impl_stability; mod _impl_stability_vector; mod _impl_variable_stability; /// A basic enum w...
true
e5f416ed793f8c21eee8e333df5a46443f6410cb
Rust
heydabop/genetic
/src/systems/print_stats.rs
UTF-8
1,049
2.75
3
[ "Unlicense" ]
permissive
use crate::components::Score; use crate::resources::{ResetInterval, Ticks}; use specs::{prelude::*, ReadExpect, ReadStorage, System}; pub struct PrintStats; impl<'a> System<'a> for PrintStats { type SystemData = ( ReadStorage<'a, Score>, ReadExpect<'a, Ticks>, ReadExpect<'a, ResetInterval>...
true
d46013a53b370b15fcc854f882bcb9ec1d0a363d
Rust
ia7ck/competitive-programming
/yukicoder/1140.rs
UTF-8
980
3.140625
3
[]
no_license
use std::io::Read; fn read<T: std::str::FromStr>() -> T { let token: String = std::io::stdin() .bytes() .map(|c| c.ok().unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } fn main() { let...
true
2f77a3ad2706a4e469aa30026441929d817f51da
Rust
FumiyukiKato/succinct-trie
/src/trie.rs
UTF-8
10,179
2.6875
3
[ "Apache-2.0" ]
permissive
use crate::config::*; use crate::louds_dense::LoudsDense; use crate::louds_sparse::LoudsSparse; use crate::builder; pub struct Trie { louds_dense: LoudsDense, louds_sparse: LoudsSparse, suffixes: Vec<Suffix>, } // 生ポインタを使えばもっと速くなる // ベクタofベクタだとキャッシュにも乗らない #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] s...
true
b0c18099a7ca8c9287bbd3c1a021f141a5554c74
Rust
zhongsp/code-kata
/LeetCode/rs/51-100/remove_duplicates_from_sorted_array_ii.rs
UTF-8
1,041
3.5
4
[]
no_license
//! https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/ struct Solution; #[allow(dead_code)] impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { let mut end = 0usize; for cur in 1..nums.len() { if nums[cur] != nums[end] { // replace ...
true
b4c710b93a1c31d201d0a579cf05de7a6cc34129
Rust
akashgurava/deckterra
/src/data/cards.rs
UTF-8
1,628
2.765625
3
[]
no_license
use std::collections::HashMap; use lordeckcodes::encoder::deck_from_code; use super::decks::Deck; lazy_static! { static ref INT_TO_FACTION: HashMap<u32, &'static str> = { let mut map = HashMap::new(); map.insert(0, "DE"); map.insert(1, "FR"); map.insert(2, "IO"); map.inser...
true
513c31a308ad4de17ed359f771e35ba62a18456a
Rust
freudshow/ucore_os_plus
/kernel/src/arch/aarch64/memory.rs
UTF-8
967
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Memory initialization for aarch64. use ucore_memory::PAGE_SIZE; use atags::atags::Atags; use crate::HEAP_ALLOCATOR; use log::*; /// Memory initialization. pub fn init() { let (start, end) = memory_map().expect("failed to find memory map"); unsafe { HEAP_ALLOCATOR.lock().init(start, end - start); ...
true
aaec87ddfcf9801f9be59da4f5837b7fd4caa579
Rust
phaylon/html5-fuser
/src/text/encoded.rs
UTF-8
3,962
3.4375
3
[ "MIT" ]
permissive
use std::str; use std::fmt; use tendril; use text; const ENCODE_CHARS: &[char] = &['&', '<', '>', '"']; fn encode_char(chr: char) -> &'static str { match chr { '&' => "&amp;", '<' => "&lt;", '>' => "&gt;", '"' => "&quot;", c => panic!("unexpected char for encode: '{}'", c...
true
9115c061bb1625b08b38dd990ed70db1dd7beced
Rust
mraof/morbitgen
/src/lib.rs
UTF-8
23,267
2.796875
3
[]
no_license
extern crate rand; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; #[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))] #[macro_use] extern crate stdweb; #[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))] extern crate yew; #[cfg(any(target_arch = "wasm32", target_arch...
true
34ce56220592f0141794b426757765a3194cf49c
Rust
Prometeo/rust_tutorial
/projects/ownership/return_values_and_scope/src/main.rs
UTF-8
968
3.9375
4
[]
no_license
// Return values can also transfer ownership fn main() { let _s1 = gives_ownership(); // gives_ownership moves its return value into s1 let s2 = String::from("Hello"); // s2 comes into scope let s3 = takes_and_gives_back(s2); // s2 is moved into takes_and_gives_back, ...
true
ab46070a864e0a3a82a33f69a7dfc2196f6f9a0d
Rust
tompreston/sup
/src/lib.rs
UTF-8
7,681
3.28125
3
[]
no_license
//! Functions and data structures for parsing IRC standup logs pub mod cli; use std::fmt; use std::io; use std::path::{Path, PathBuf}; use std::str::FromStr; use thiserror::Error; /// Some errors which might occur when running sup #[derive(Error, Debug)] pub enum StandupError { /// When an IO error occurrs #[...
true
a9a30a0c29f9caeb452c6708e09cfdc394babfd7
Rust
attilahorvath/exercism-rust
/pangram/src/lib.rs
UTF-8
281
2.875
3
[ "MIT" ]
permissive
pub fn is_pangram(sentence: &str) -> bool { let mut chars = sentence .to_lowercase() .chars() .filter(|&c| c >= 'a' && c <= 'z') .collect::<Vec<_>>(); chars.sort(); chars.dedup(); chars.len() == ('z' as usize - 'a' as usize + 1) }
true
b9d41b735a5617e364d30a2cc89fe993022536e9
Rust
kedia-project/stellar-base-rs
/src/operations/path_payment_strict_receive.rs
UTF-8
11,550
2.765625
3
[ "Apache-2.0" ]
permissive
use crate::amount::Stroops; use crate::asset::Asset; use crate::crypto::MuxedAccount; use crate::error::{Error, Result}; use crate::operations::Operation; use crate::xdr; use std::convert::TryInto; #[derive(Debug, Clone, PartialEq, Eq)] pub struct PathPaymentStrictReceiveOperation { source_account: Option<MuxedAcc...
true
c13c139df7a08075b692bf833cbf36a9a664b579
Rust
modelflat/wallpaper-rs
/src/wallpaper.rs
UTF-8
16,868
2.5625
3
[ "Unlicense" ]
permissive
use std::ffi::{OsStr, OsString}; use std::iter::once; use std::os::windows::ffi::{OsStrExt, OsStringExt}; use std::ptr::null_mut; use std::process::Command; use serde::{Serialize, Deserialize}; use winapi::shared::windef::{HWND, RECT, PPOINT, POINT}; use winapi::shared::minwindef::LPARAM; use winapi::um::errhandlinga...
true
cfd33aa01068649336ad5cb675a41f29260ac0b1
Rust
On0n0k1/kik_sync_service
/src/kik_message.rs
UTF-8
2,831
3.546875
4
[ "MIT" ]
permissive
//! # Messages //! //! Traits for defining how the channel should transfer, work and retrieve the messages. //! Users have to implement these traits in their data structure before using the *DeliveryService*. //! //! The type with the *Message* trait must be able to hold types that implement *MessageData* and *Messag...
true
8839273cd3af49888173c1dba6f8139a8e343722
Rust
pvdrz/cryptopals-old
/src/encoding/base64.rs
UTF-8
2,082
3.125
3
[]
no_license
use std::collections::HashMap; pub struct Base64 { enc: Vec<u8>, dec: HashMap<u8, u8>, padding: u8 } impl Base64 { pub fn new() -> Self { let enc: Vec<u8> = (b'A'..b'Z'+1) .chain(b'a'..b'z'+1) .chain(b'0'..b'9'+1) .chain([b'+', b'/'].iter().cloned()) ...
true
ab1b616cc983d0d1361928ed9360ac807f3d63ed
Rust
lcnr/computer
/rock/src/token.rs
UTF-8
6,546
3.375
3
[]
no_license
use std::ops::Range; #[derive(Debug, Clone, Copy)] pub enum TokenType { Byte(u8), Ident, Section, QualifiedSection, A, B, C, D, Mem, BlockAddr, SectionAddr, Colon, SemiColon, Invalid, } #[derive(Debug, Clone)] pub struct Token<'a> { line: usize, origin: ...
true
d9821ab1bdb398372485f5e5fb7b621fd52b2088
Rust
Ameobea/phoenix-rs
/src/socket.rs
UTF-8
3,404
2.78125
3
[]
no_license
use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::{thread, time}; use serde_json; use websocket::client::ClientBuilder; use websocket::{Message, OwnedMessage}; use chan::Channel; use event::{Event, PhoenixEvent}; use message::Message as PhoenixMessage; pub struct Phoenix { tx: ...
true
418adf884fdd92cc7076c39438ca0709db490200
Rust
bsed/rust_example
/mutex/src/main.rs
UTF-8
1,642
3.1875
3
[ "MIT" ]
permissive
use std::sync:: {Arc, Mutex}; use std::thread; fn main() { println!("Hello, world!"); let mutex = Arc::new(Mutex::new(0)); let c_mutex = Arc::clone(&mutex); let t1 = thread::spawn(move || { let mut count = c_mutex.lock().unwrap(); println!("-----------------------------"); prin...
true
4dc13b680cd0f0fcbdba48ff946ba6530c8e0f1e
Rust
wolfgang/tetrs
/src/_tests/helpers/to_string_renderer.rs
UTF-8
1,980
3.09375
3
[]
no_license
use crate::game::trenderer::TRenderer; use crate::_tests::helpers::brick_type::brick_type_to_char; pub struct ToStringRenderer { pub frame: Vec<Vec<char>>, width: usize, use_brick_type_encoding: bool } impl ToStringRenderer { pub fn default() -> ToStringRenderer { Self::new(10, 16) } ...
true
dcf2e5f7fc5822fa9df091a87da2cb18317e2e13
Rust
Wint3rmute/tiler
/src/layouts.rs
UTF-8
3,822
3.203125
3
[]
no_license
use crate::size_settings::SizeSettings; use crate::wmctrl_window; use crate::{hp, wp}; use std::mem::swap; // Extra positioning helpers impl wmctrl_window::WmctrlWindow { // Maybe use it for some size-specific rules some day? /* fn get_field(&self) -> i32 { return self.width as i32 * self.height as...
true
d35e2f4f3bdee8d81c2080048d7ad96f406628fb
Rust
TimonPost/anasaizi
/anasaizi-core/src/engine/resources/texture_loader.rs
UTF-8
1,384
2.78125
3
[]
no_license
use crate::engine::{ resources::{load_image_path, TextureStorage}, RenderContext, }; use std::sync::{Arc, Mutex}; use tokio::task::JoinHandle; pub struct TextureLoader { storage: Arc<Mutex<TextureStorage>>, load_tasks: Vec<JoinHandle<()>>, render_context: Arc<RenderContext>, debug: bool, } imp...
true
15d6ec6be196cba77781af607af355254d93d023
Rust
stm32-rs/stm32-rs-nightlies
/stm32h5/src/stm32h562/cordic.rs
UTF-8
1,925
2.546875
3
[]
no_license
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - CORDIC control/status register"] pub cordic_csr: CORDIC_CSR, #[doc = "0x04 - CORDIC argument register"] pub cordic_wdata: CORDIC_WDATA, #[doc = "0x08 - CORDIC result register"] pub cordic_rdata: CORDIC_RDATA, } #[do...
true
86dd2381378f13dc07129e41ef272d7d93a338b7
Rust
BerenMillidge/RustTutorials
/src/struct.rs
UTF-8
884
3.96875
4
[]
no_license
#[derive(Debug)] struct Rectangle { width: u32, height: u32 } // to define a method on a struct - i.e. more like a standard objec, you use the impl keyword block impl Rectangle { fn area(&self) -> u32 { self.width * self.height } fn can_hold(&self, other: &Rectangle) -> bool { return self.width > other.wid...
true
9562855b6abb88f135fc00387469ac14b42650fc
Rust
sh1yu/simple-lexer
/src/lib.rs
UTF-8
973
2.890625
3
[]
no_license
mod lexer; mod token; use lexer::SimpleLexer; use token::TokenReader; pub fn simple_lexer_demo() { let mut l = SimpleLexer::new(); let mut script = String::from("int age = 45;"); println!("parse :{}", script); let mut token_reader = l.tokenize(script); token_reader.dump(); //测试inta的解析 sc...
true
f0e7c7f348a5cbd6a2e02ea0d92959a681b7bc52
Rust
chrisquion/city-is-ogre
/src/inventory.rs
UTF-8
632
2.984375
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] pub struct Inventory { bags: Vec<Bag>, } impl Inventory { pub fn new() -> Inventory { let bags: Vec<Bag> = Vec::new(); Inventory { bags } } } #[derive(Debug, Deserialize, Serialize)] struct B...
true
6c1ff59f75b9f97e2957b2b19db31d521212c79b
Rust
JonnyWalker81/aoc-2020
/aoc04/src/main.rs
UTF-8
5,258
3.15625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::io::{self, Read}; type Result<T> = ::std::result::Result<T, Box<dyn::std::error::Error>>; fn main() -> Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; part1(&input)?; part2(&input)?; Ok(()) } fn collect_passports(input...
true
8cfd4bd4635bcadf4c989fcecddbc75f07c295ed
Rust
jfblg/deadwiki
/src/main.rs
UTF-8
2,570
2.84375
3
[ "MIT" ]
permissive
use deadwiki::{app, sync}; fn main() { let args = std::env::args().skip(1).collect::<Vec<String>>(); let mut args = args.iter(); let mut path = ""; let mut host = "0.0.0.0"; let mut port = 8000; let mut sync = false; #[cfg(feature = "gui")] let mut gui = false; while let Some(arg) ...
true
98d68b16ba417d2eac9b649981322237896aa9f2
Rust
harski/todo
/src/todo_item.rs
UTF-8
4,951
2.921875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2016 Tuomo Hartikainen <tth@harski.org>. // Licensed under the 2-clause BSD license, see LICENSE for details. use std::cmp::Ordering; use std::fs::File; use std::io::{Error, ErrorKind, Read}; use std::path::Path; use std::str::Lines; use time; use time::Tm; use attr::Attr; use error::TodoResult; use sta...
true
3b9172d3b3edbc8b1addbfe315b4fd1d3e23e802
Rust
Michael-F-Bryan/tokio
/tokio-threadpool/src/notifier.rs
UTF-8
1,261
2.8125
3
[ "MIT" ]
permissive
use pool::Inner; use task::Task; use std::mem; use std::sync::Weak; use futures::executor::Notify; /// Implements the future `Notify` API. /// /// This is how external events are able to signal the task, informing it to try /// to poll the future again. #[derive(Debug)] pub(crate) struct Notifier { pub inner: We...
true
07b9376199ea9241a4e7d0b040429e99193a9acf
Rust
kamranajabbar/ch_10_generic_trait_lifetime
/src/traits_with_bound_syntax.rs
UTF-8
1,011
3.28125
3
[]
no_license
pub fn run() { #[derive(Debug)] struct Tweet { username: String, content: String, } #[derive(Debug)] struct NewsArtical { author: String, content: String, } pub trait Summary { fn summarize(&self)->String; } impl Summary for Tweet { ...
true
28245c2a2dfcf2f685378a3c0cf84446e7a3d013
Rust
lars-petter-hauge/aoc
/2018/rust/day2/src/main.rs
UTF-8
2,962
3.515625
4
[]
no_license
use std::io::prelude::*; use std::path::Path; use std::collections::HashMap; extern crate itertools; use itertools::Itertools; fn load_from_file(filename: impl AsRef<Path>)-> Vec<String> { let file = std::fs::File::open(filename).expect("could not open line"); let buf = std::io::BufReader::new(file); buf....
true
db08e31e66e781465321d57b61603131ec172138
Rust
keichi/picoscheme
/src/interpreter.rs
UTF-8
1,825
2.9375
3
[]
no_license
use std::fs::File; use std::io::{self, BufReader, Write}; use std::path::Path; use std::rc::Rc; use environment::Environment; use evaluator::eval; use lexer::Lexer; use parser::Parser; pub struct Interpreter { env: Rc<Environment>, } impl Interpreter { pub fn new() -> Self { Interpreter { ...
true
a8ce826c441558de877cd1c44c2c7a3454eff32b
Rust
smccauliff/advent-of-code-2020
/src/dec2-1/dec2-1.rs
UTF-8
1,590
2.78125
3
[ "Unlicense" ]
permissive
#[macro_use] extern crate lazy_static; use std::env; use a2020::process_lines; use regex::Regex; fn process_password(line : &String, policy_1_total: &mut usize, policy_2_total : &mut usize) { lazy_static! { static ref RE: Regex = Regex::new(r"^(\d+)-(\d+) (\S): (\S+)$").unwrap(); } let captures = ...
true
f3ff10caa13e37e03b9a43da2c358172861a4211
Rust
DavidAmison/adventofcode2020
/day12/src/position.rs
UTF-8
2,544
3.8125
4
[ "MIT" ]
permissive
use std::ops::Add; #[derive(Debug, Copy, Clone)] pub struct Direction<T> { pub dir: T, pub val: i32, } impl <T>Direction<T> where T: Copy, T: Clone, { pub fn new(dir: T, val: i32) -> Self { Direction::<T>{ dir, val, } } } impl <T>Add for Direction<T> { ...
true
613e7327eb23b15f194056afc98329aad776bdd7
Rust
smoltcp-rs/smoltcp
/src/wire/ndiscoption.rs
UTF-8
27,259
2.859375
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use bitflags::bitflags; use byteorder::{ByteOrder, NetworkEndian}; use core::fmt; use super::{Error, Result}; use crate::time::Duration; use crate::wire::{Ipv6Address, Ipv6Packet, Ipv6Repr, MAX_HARDWARE_ADDRESS_LEN}; use crate::wire::RawHardwareAddress; enum_with_unknown! { /// NDISC Option Type pub enum Typ...
true
49c58ca581e5eff8172e51e02c6c2ae3d565372c
Rust
icub3d/puzzles
/advent-of-code/2020/day16/src/main.rs
UTF-8
3,633
3.234375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::collections::HashMap; use std::collections::HashSet; fn main() { let file = File::open("input").unwrap(); let buf = BufReader::new(file); let aa: Vec<String> = buf.lines().map(|l| l.unwrap()).collect(); // Gather rules let ...
true
241437f1e0fb3ce03dd52057fccd89fa9c7e2ba9
Rust
qiongtubao/latte_learn_rust
/example/iscoped-threadpool/src/main.rs
UTF-8
327
2.859375
3
[]
no_license
extern crate scoped_threadpool; use scoped_threadpool::Pool; fn main() { let mut pool = Pool::new(4); let mut vec = vec![0,1,2,3,4,5,6,7]; pool.scoped(|scope| { for e in &mut vec { scope.execute(move || { *e += 1; }); } }); println!("{:?}", v...
true
37e8d8f53cd584233bf48eecf7f63e1789bf997f
Rust
smarnach/crates.io
/src/bin/transfer-crates.rs
UTF-8
2,609
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
// Transfer all crates from one user to another. // // Usage: // cargo run --bin transfer-crates from-user to-user #![deny(warnings, clippy::all, rust_2018_idioms)] use cargo_registry::{ db, models::{Crate, OwnerKind, User}, schema::{crate_owners, crates, users}, }; use std::{ env, io::{self,...
true
160b6806a5080008b89609d6ca8ced84cf2ff15a
Rust
agausmann/declio
/declio/src/util.rs
UTF-8
8,968
3.390625
3
[ "MIT" ]
permissive
//! Utilities that aren't part of the "core" of declio, but may be useful in reducing boilerplate. use crate::ctx::{Endian, Len}; use crate::{Decode, Encode, Error}; #[doc(inline)] pub use crate::magic_bytes; macro_rules! endian_wrappers { ($($(#[$attr:meta])* $name:ident: $endian:expr,)*) => {$( $(#[$at...
true
2f937b2f309f8f11bf99539aa66e765933cc7fd3
Rust
zipkr/sol-db
/src/main.rs
UTF-8
4,197
2.8125
3
[]
no_license
extern crate rand; extern crate uuid; extern crate stopwatch; use std::fs::{self, File, OpenOptions}; use std::error::Error; use std::time::{SystemTime, UNIX_EPOCH}; use std::collections::HashMap; use std::io::{BufReader, LineWriter}; use std::io::prelude::*; use std::thread; use uuid::Uuid; use rand::prelude::*; use...
true
0548af40af98d536c158b8477b9293880916bc0a
Rust
atuinsh/atuin
/atuin/src/command/client/sync.rs
UTF-8
2,643
2.65625
3
[ "MIT" ]
permissive
use clap::Subcommand; use eyre::{Result, WrapErr}; use atuin_client::{ database::Database, record::{store::Store, sync}, settings::Settings, }; mod status; use crate::command::client::account; #[derive(Subcommand)] #[command(infer_subcommands = true)] pub enum Cmd { /// Sync with the configured serv...
true
20c3ce358d6f961d9c24bb868c908e5856bdce93
Rust
alekratz/file-lang
/src/syn/error.rs
UTF-8
549
2.53125
3
[]
no_license
use crate::common::span::Span; use snafu::Snafu; #[derive(Debug, Snafu)] pub enum SyntaxError { #[snafu(display("expected {}, but got {} instead", expected, got))] ExpectedGot { span: Span, expected: String, got: String, }, #[snafu(display("unexpected {}", what))] Unexpecte...
true
d409d5c147ab11eb789c3e67936a07edf33f21f5
Rust
Kinto/kinto-http.rs
/src/collection.rs
UTF-8
8,207
2.71875
3
[ "Apache-2.0" ]
permissive
use serde_json; use serde_json::Value; use KintoConfig; use error::KintoError; use request::KintoRequest; use response::ResponseWrapper; use resource::Resource; use bucket::Bucket; use record::Record; use utils::unwrap_collection_records; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Collection...
true
8d0dcbe6405044bb863b6186f4649c4ee1e536c8
Rust
loiclec/fuzzcheck-rs
/fuzzcheck/src/mutators/enums.rs
UTF-8
4,428
2.828125
3
[ "MIT" ]
permissive
use std::any::Any; use crate::Mutator; /// Trait used by the [DefaultMutator derive macro](fuzzcheck_mutators_derive::DefaultMutator) /// for enums without associated data pub trait BasicEnumStructure { fn from_variant_index(item_index: usize) -> Self; fn get_variant_index(&self) -> usize; } /// A mutator us...
true
b51642ad7893812dda4bc707944f36c43c7616cc
Rust
niuez/rust-data-structures
/src/container/vector.rs
UTF-8
2,815
3.25
3
[]
no_license
use std::mem; use std::ptr::{ NonNull, self }; use std::alloc::{ Layout, alloc, realloc, dealloc }; pub struct Vector<T> { ptr: NonNull<T>, cap: usize, len: usize, } impl<T> Vector<T> { pub fn new() -> Self { assert!(mem::size_of::<T>() != 0, "We're not ready to handle ZSTs"); Vector...
true
c1dd677d370fca7a46413d10d3c99c74d449fe67
Rust
RustAudio/dasp
/dasp_graph/src/node/boxed.rs
UTF-8
2,873
2.921875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::{Buffer, Input, Node}; use core::fmt; use core::ops::{Deref, DerefMut}; /// A wrapper around a `Box<dyn Node>`. /// /// Provides the necessary `Sized` implementation to allow for compatibility with the graph process /// function. pub struct BoxedNode(pub Box<dyn Node>); /// A wrapper around a `Box<dyn Node...
true
8837be8aec2532a0bd47a465b1ec3936d64d5836
Rust
binast/binjs-ref
/crates/binjs_es6/src/lazy.rs
UTF-8
7,427
3.0625
3
[ "MIT" ]
permissive
use ast::*; use EnrichError; use binjs_shared::{Offset, VisitMe}; use std; use std::cell::RefCell; use std::rc::Rc; type EnterResult = Result<VisitMe<Option<LevelGuard>>, EnrichError>; type ExitResult<T> = Result<Option<T>, EnrichError>; /// Keep track of the number of nested levels of functions/methods/... /// we ...
true
05627e8202c73de21707ffb1cb2a378fdfdbc5d1
Rust
alexarice/aoc2020
/day19/main.rs
UTF-8
3,125
3.109375
3
[]
no_license
use nom::{ branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*, sequence::*, IResult, }; use regex::Regex; use std::collections::HashMap; use std::fs; #[derive(Debug)] enum Rule { Letter(char), Compound(Vec<Vec<u32>>), } type RuleList = HashMap<u32, Rule>; use Rule::*; fn ...
true
3b8c516670f82c8454823f916e9f6c9a343ce633
Rust
mfarzamalam/Rust
/chap19/src/main.rs
UTF-8
491
2.9375
3
[]
no_license
fn main() { // let mut num =4 ; // num = 5; // println!("value {} " , num) ; // println!("reference : {:p}" , &num) ; // pointer value keep changing, why ? // println!("Binary : {:b}" , &num) ; // println!("reference : {:x}" , &num) ; let mut num = 5; let r1 = &num as *cons...
true
c976ced724554057f41b85e90ed5b8d9407a0d47
Rust
carzacc/conversione-rust
/src/main.rs
UTF-8
808
2.59375
3
[]
no_license
extern crate iron; extern crate router; mod html; use router::Router; use iron::request::*; use iron::Response; use iron::prelude::*; use iron::status; use iron::mime::Mime; fn main() { let mut router = Router::new(); router.get("/", invia_form, "radice"); // Molto simile alla sintassi che si usa con Express...
true
987ef18be43596aec6ddabc4635ccd26e2d08350
Rust
triplef87/advent_of_code_2016
/day_08/src/main.rs
UTF-8
2,158
3.171875
3
[]
no_license
use std::{io, fs::File}; use io::BufRead; fn main() { let mut screen = vec![vec![false; 50]; 6]; let file = File::open("input").expect("Open file error!"); io::BufReader::new(file) .lines() .map(|x| x.expect("Read line error!")) .for_each(|row| { let splits: Vec<&str> =...
true
661c36ef29ef73001c1cb2c59004b18ea3a0425b
Rust
davidMcneil/structopt
/tests/default_value.rs
UTF-8
1,580
3.34375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use structopt::StructOpt; mod utils; use utils::*; #[test] fn auto_default_value() { #[derive(StructOpt, PartialEq, Debug)] struct Opt { #[structopt(default_value)] arg: i32, } assert_eq!(Opt { arg: 0 }, Opt::from_iter(&["test"])); assert_eq!(Opt { arg: 1 }, Opt::from_iter(&["test...
true
79f1e516bb93fd697c662aa861e56dc883f95dd5
Rust
HuixingWong/RustLearning
/src/data_type.rs
UTF-8
488
4
4
[]
no_license
pub fn data_type() { let x = 52u32; println!("{}", x); //奇怪的类型 ,,,, let tup: (i32, f64, u8, String) = (500, 6.4, 1, "h哈哈".to_string()); let (x, y, z, f) = tup; println!("The value of y is: {}", y); println!("The value of f is: {}", f); //array let a = [1, 2, 3, 4, 5]; let a:...
true
4a43116ce85154df115426cde3e9a52351963198
Rust
mason0510/rust-stratum-v2
/stratumv2/src/macro_message/setup_connection_success.rs
UTF-8
2,720
2.765625
3
[]
no_license
pub mod macro_prelude { pub use crate::error::{Error, Result}; pub use crate::impl_message; pub use crate::types::MessageType; pub use std::io; } #[doc(hidden)] #[macro_export] macro_rules! impl_setup_connection_success { ($flags_type:ident) => { use crate::macro_message::setup_connection_s...
true
543781763124df7ca6e753a032179e3c1ecd9492
Rust
BurntSushi/tabwriter
/src/test.rs
UTF-8
5,737
2.71875
3
[ "MIT", "Unlicense" ]
permissive
use crate::Alignment; use crate::TabWriter; use std::io::Write; fn ordie<T, E: ToString>(r: Result<T, E>) -> T { match r { Ok(r) => r, Err(e) => panic!("{}", e.to_string()), } } fn readable_str(s: &str) -> String { s.replace(" ", "·") } fn tabw() -> TabWriter<Vec<u8>> { TabWriter::new...
true
23293c2f85838a7cd1758599ab0e781a474de7f9
Rust
mettke/tenable-rs
/src/types/mod.rs
UTF-8
2,646
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Tenable Types returned or expected by server mod acr_update; mod asset_by_uuid; mod assets; mod assets_move; pub use acr_update::*; pub use asset_by_uuid::*; pub use assets::*; pub use assets_move::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] /// `Source` bl...
true
7878243992dcd7d2807b26f05cf5d7fd92074733
Rust
ajohnstonTE/TFBVerifier
/src/verification.rs
UTF-8
7,037
3.359375
3
[ "BSD-3-Clause" ]
permissive
//! The `Verification` module is the mechanism by which `TFBVerifier` communicates //! verification data to the `TFBToolset`. //! By default, nearly anything printing to stdout/stderr will simply be //! consumed by the toolset and then printed to stdout/stderr. However, in //! order to pass data about the state of the ...
true
25384387e8ed089634e1679a444fada95e87b7f8
Rust
tkmct/kadrs
/src/bin/anonymous_client.rs
UTF-8
2,311
2.828125
3
[]
no_license
use { clap::{App, Arg, ArgMatches, SubCommand}, kadrs::{ error::{Error, Result}, request::Request, rpc::Rpc, }, std::net::SocketAddrV4, }; fn parse_method(matches: ArgMatches) -> Result<Rpc> { if let Some(_) = matches.subcommand_matches("ping") { return Ok(Rpc::Ping)...
true
559c9fb88f6597d925cce09e53117ee472133578
Rust
arkark/atcoder-auto-tester
/src/detector.rs
UTF-8
2,953
2.703125
3
[ "MIT" ]
permissive
use std::env; use std::thread; use std::time; use inotify::{EventMask, Events, Inotify, WatchMask}; use itertools::Itertools; use crate::error::ErrorHandleable; pub struct Detector { inotify: Inotify, buffer: [u8; 4096], } impl Default for Detector { fn default() -> Self { let mut inotify = Inot...
true
849242833403c4774cbcabfd3bbc0f41deff55bd
Rust
av-ast/rust_learning
/json_parsing/src/main.rs
UTF-8
1,250
3.171875
3
[]
no_license
use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] struct Todo { #[serde(rename = "userId")] user_id: i32, id: Option<i32>, title: String, completed: bool, } #[tokio::main] async fn main() -> Result<(), reqwest::Error> { let todos: Vec<Todo> = reqwest::Client::new() ...
true
65233af7524de062855dc3d2c89481fcb9d70a74
Rust
RustCrypto/block-ciphers
/aes/src/ni/test_expand.rs
UTF-8
10,752
2.53125
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
use super::utils::check; use hex_literal::hex; #[test] fn aes128_expand_key_test() { use super::aes128::expand_key; let keys = [0x00; 16]; check( unsafe { &expand_key(&keys) }, &[ [0x0000000000000000, 0x0000000000000000], [0x6263636362636363, 0x6263636362636363], ...
true
224160ff9eb4c44f393aca6a9f8783f9f9703f76
Rust
tirust/msp432e4
/src/emac0/lpictlstat.rs
UTF-8
16,931
2.6875
3
[ "BSD-3-Clause" ]
permissive
#[doc = r"Value read from the register"] pub struct R { bits: u32, } #[doc = r"Value to write to the register"] pub struct W { bits: u32, } impl super::LPICTLSTAT { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&...
true
c6fa30ad2946e2afd81af3d75b45a0c1c049110a
Rust
ambuc/aoc-2017-rust
/14.rs
UTF-8
3,553
3.296875
3
[]
no_license
mod knot_hash; use std::collections::HashSet; #[derive(Debug)] struct Graph { nodes: HashSet<(i32, i32)>, } impl Graph { fn new() -> Graph { Graph { nodes: HashSet::new(), } } fn num_regions(&self) -> i32 { let mut visited: HashSet<(i32, i32)> = HashSet::new(); ...
true
e63cffe3ffa2b693b2660a533a71d76b5f385460
Rust
IntrepidPig/wl
/wl_scanner/src/generator/helpers.rs
UTF-8
1,257
3.25
3
[]
no_license
pub struct StructDefinition { pub derives: String, pub name: String, pub visibility: String, pub data: StructData, } pub enum StructData { Unit, Tuple(Vec<String>), Fields(Vec<(String, String)>), } pub fn define_struct(def: &StructDefinition) -> String { format!("#[derive({})]{} struct {}{}", def.derives, def...
true
4ad6deeec15a67c4b9c6be4afbc50300f3784474
Rust
fparisotto/yape
/examples/random.rs
UTF-8
890
2.984375
3
[ "MIT" ]
permissive
use yape::{YapeCallback, YapeEngineApi, YapeEngine, YapeResult, Pixel}; use rand::{thread_rng, Rng}; use rand::rngs::ThreadRng; struct RandomPixel { rng: ThreadRng } impl YapeCallback for RandomPixel { fn on_create(&mut self) -> YapeResult<bool> { Ok(true) } fn on_update(&mut self, engine: &m...
true
848c329c2b180722232d4b12b65eae1254b2e6fb
Rust
Chococrok/rust-format-csv
/src/main.rs
UTF-8
3,320
3.21875
3
[]
no_license
use std::env; use std::fs::File; use std::io::prelude::*; use std::io::{BufReader, Result}; use std::path::Path; fn main() -> Result<()> { let config = get_global_config(); let iter = config .inputs .iter() .filter_map(|input| File::open(input).ok()) .map(BufReader::new) ...
true
6bd9593ee848f017eba3a7e74ba1a220d25940e4
Rust
eoan-ermine/furryfox
/src/problem/middle/extern_url_with_double_brackets/mod.rs
UTF-8
1,102
2.625
3
[]
no_license
use lazy_static::lazy_static; use regex::{Captures, Regex}; use crate::problem::Problem; lazy_static! { static ref URL_WITH_DOUBLE_BRACKETS_RE: Regex = Regex::new(r"^\[\[((?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3...
true
5c186d87dbf0883e5ca74781b3c1667bf8b76de2
Rust
JackMordaunt/monkey
/src/repl.rs
UTF-8
970
2.984375
3
[]
no_license
use crate::lexer::Lexer; use crate::parser::Parser; use std::io::prelude::*; use std::error::Error; use colored::*; const PROMPT: &'static str = ">>"; pub fn start<R, W>(r: &mut R, w: &mut W) where R: BufRead, W: Write, { let mut line = String::new(); loop { line.clear(); if let Err(err)...
true
f99a17d97e3e496914641f0bcf1175dd2718f173
Rust
4x7y/nurbs-rs
/src/geometry/bspline.rs
UTF-8
12,037
2.703125
3
[]
no_license
use na::*; use na::allocator::Allocator; use crate::math::Scalar; use std::rc::Rc; use std::cell::RefCell; use kiss3d::resource::Mesh; use crate::geometry::helper::*; #[derive(Debug, Clone)] pub struct BSplineCurve<D: Dim + DimName> where DefaultAllocator: Allocator<Scalar, D> { pub ctrlpts: Vec<VectorN<Scalar...
true
45b965f1530a45ea43e8449de0ad2d50bd908d4d
Rust
rcore-os/zCore
/kernel-hal/src/utils/page_table.rs
UTF-8
9,852
2.65625
3
[ "MIT" ]
permissive
use crate::{common::vm::*, mem::PhysFrame, MMUFlags, PhysAddr, VirtAddr}; use alloc::vec::Vec; use core::{fmt::Debug, marker::PhantomData, slice}; use lock::Mutex; pub trait PageTableLevel: Sync + Send { const LEVEL: usize; } pub struct PageTableLevel3; pub struct PageTableLevel4; impl PageTableLevel for PageTab...
true
a588b3bc12e86934b81bf2541d1732b845f7e139
Rust
mraerino/aya
/aya/src/maps/stack_trace.rs
UTF-8
7,482
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
//! A hash map of kernel or user space stack traces. //! //! See [`StackTraceMap`] for documentation and examples. use std::{ collections::BTreeMap, convert::TryFrom, fs, io, mem, ops::Deref, path::Path, str::FromStr, }; use crate::{ generated::bpf_map_type::BPF_MAP_TYPE_STACK_TRACE, maps::{IterableMap, Ma...
true
1d02ea903f7c836468b2a1e041da0c68337528b9
Rust
brynelee/rust_trial_repo
/variables_test/src/hash_test.rs
UTF-8
950
3.8125
4
[]
no_license
pub mod hash_demo { use std::collections::HashMap; pub fn hash_demo_func() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"), 50); // 遍历得到 K/V for (key, value) in &scores { println!("{}: {}", k...
true
4e4ec75622a068cce92264751d205557917f952b
Rust
meehawk/deno
/cli/fs_util.rs
UTF-8
8,936
3.109375
3
[ "MIT" ]
permissive
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; pub use deno_core::normalize_path; use deno_runtime::deno_crypto::rand; use std::env::current_dir; use std::fs::OpenOptions; use std::io::{Error, Write}; use std::path::{Path, PathBuf}; use walkdir::WalkDir; pub...
true
4217e2b9cd4f34a51d0bedf074035a018e3e5615
Rust
kamadak/exif-rs
/src/util.rs
UTF-8
6,268
2.59375
3
[ "BSD-2-Clause" ]
permissive
// // Copyright (c) 2016 KAMADA Ken'ichi. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of con...
true
408af4fba22529d0d39665b77b232a4ecff870ed
Rust
WalrusCodes/adv2020
/src/day20.rs
UTF-8
13,763
3.1875
3
[]
no_license
#![allow(dead_code)] use std::collections::HashMap; mod lib; // Width (and height) of each tile. const SIZE: usize = 10; // One row/side of each tile. type Line = u16; #[derive(PartialEq, Eq, Debug, Clone, Hash, Default)] struct Tile { id: usize, rows: Vec<Line>, flipped: bool, rotated: u32, } fn ...
true
c8308bf3e7fc7f379f50de5030745a5da67eccfc
Rust
zDevelopers/Panoptes
/back/src/area.rs
UTF-8
2,632
3.140625
3
[]
no_license
use std::collections::HashMap; use itertools::Itertools; use serde::Serialize; use crate::config::{AreasConfig, ConfigArea}; /// All areas declared into the configuration file are stored in this structure, made available /// through a state. #[derive(Serialize, Debug, Clone)] pub(crate) struct Areas { pub areas:...
true