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
30202c8f3ddae485a30b2aaaaa6c755b11c522a9
Rust
danbruder/rush
/src/cmd.rs
UTF-8
7,712
3.21875
3
[]
no_license
use std::convert::TryFrom; use std::ffi::OsStr; use std::io::{self, Write}; use std::process::{self, Command}; use std::str::SplitWhitespace; use std::vec::IntoIter; pub enum Expression<'a> { Cmd(Cmd<'a>), Compound(Box<Compound<'a>>), } #[derive(Debug)] pub enum Cmd<'a> { // An invokable command consists...
true
8635136516f0be05ed15d7e1a46ad885798a9f9c
Rust
RazrFalcon/ttf-parser
/src/tables/hmtx.rs
UTF-8
3,856
3.40625
3
[ "Apache-2.0", "MIT", "GPL-2.0-only", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A [Horizontal/Vertical Metrics Table]( //! https://docs.microsoft.com/en-us/typography/opentype/spec/hmtx) implementation. use core::num::NonZeroU16; use crate::parser::{FromData, LazyArray16, Stream}; use crate::GlyphId; /// Horizontal/Vertical Metrics. #[derive(Clone, Copy, Debug)] pub struct Metrics { ///...
true
7a963d2ed0dd9a284b1c3b9508656297f7753f78
Rust
kamyau/tari-university
/src/cryptography/digital_signatures/src/aggregation_1.rs
UTF-8
1,294
2.703125
3
[ "Apache-2.0" ]
permissive
extern crate libsecp256k1_rs as secp256k1; use secp256k1::{SecretKey, PublicKey, thread_rng, Message}; use secp256k1::schnorr::{Schnorr, Challenge}; #[allow(non_snake_case)] fn main() { // Alice generates some keys let (ka, Pa, ra, Ra) = get_keyset(); // Bob generates some keys let (kb, Pb, rb, Rb) = ...
true
f345a1e669ce9e9139fc3dd186627f8332b7523d
Rust
shmel1k/kafka-proxy
/src/ratelimit/src/config.rs
UTF-8
541
2.640625
3
[ "Apache-2.0" ]
permissive
use crate::Rule; use serde::Deserialize; #[derive(Clone, Deserialize)] pub struct Config { pub rules: std::vec::Vec<Rule>, pub enabled: bool, } impl Default for Config { fn default() -> Self { Config::default_config() } } impl Config { fn default_config() -> Self { Config { ...
true
17f65ee9129aa87f6d4f3e42d799b2d87d9d2926
Rust
vicentedpsantos/rust-by-example
/src/primitives/primitives.rs
UTF-8
1,610
3.640625
4
[]
no_license
// Rust provides a way to access a wide variety of primitives. A sample includes: // Scalar Types // signed integers: i8, i16, i32, i64, i128 and isize (pointer size) // unsigned integers: u8, u16, u32, u64, u128, usize (pointer size) // floating point: f32, f64 // char: unicode containing scalar values like 'a', 'α',...
true
250cc9a5da36334a8b601280dc230471bedffcc4
Rust
indygreg/starlark-rust
/starlark/src/collections/stack.rs
UTF-8
3,159
2.71875
3
[ "Apache-2.0" ]
permissive
/* * Copyright 2019 The Starlark in Rust Authors. * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/lic...
true
2e3d79cdd32b431de83a0cd208c42a1276ed2992
Rust
ferhatgec/shiru
/structure/cpp/src/main.rs
UTF-8
1,565
2.59375
3
[ "MIT" ]
permissive
extern crate shiru; use shiru::{ Highlight, LanguageData, shiru_cpp::c_plus_plus, parse::{ Parse } }; fn main() { let mut parse : Parse = Parse { highlight: Highlight { data: LanguageData { keywords: vec![], colors: vec![], bu...
true
6bbfd4610cc80ee7dea6bcb3e3500923145345ae
Rust
sd2k/aoc-2020
/src/day10.rs
UTF-8
4,980
3.21875
3
[]
no_license
use std::collections::HashMap; use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day10)] fn parse_input(input: &str) -> Vec<usize> { input.lines().map(|el| el.parse().unwrap()).collect() } #[aoc(day10, part1)] fn part1(input: &[usize]) -> usize { let mut input = input.to_vec(); input.sort_unst...
true
e38975b5049642bfff925298bd8d9f077f2dce38
Rust
mdu02/ferric-8
/src/byte_register.rs
UTF-8
1,086
3.71875
4
[ "MIT" ]
permissive
pub struct ByteRegister { value: u8, name: String } impl ByteRegister { pub fn new(name: String) -> ByteRegister { let mut reg : ByteRegister = ByteRegister { value: 0, name}; reg } pub fn read_reg(&self) -> u8 { self.value } pub fn write_reg(&mut self, val: u8) { ...
true
1ec236ed6c1284282dc2bd56593f0703a4ed170d
Rust
freestrings/rtag
/src/metadata.rs
UTF-8
30,680
2.59375
3
[ "MIT" ]
permissive
pub extern crate regex; extern crate flate2; use self::flate2::Compression; use self::flate2::read::ZlibDecoder; use self::flate2::write::ZlibEncoder; use frame::*; use frame::types::*; use rw::{Readable, Writable}; use std::cell::RefCell; use std::fs::{File, OpenOptions}; use std::io::{Cursor, Error, ErrorKind, Res...
true
77c91ddc835d904c8078199e3b606ebf593eee51
Rust
daotlresearch/cddl
/src/validator/mod.rs
UTF-8
20,440
2.734375
3
[ "MIT" ]
permissive
/// CBOR validation implementation pub mod cbor; /// JSON validation implementation pub mod json; use cbor::CBORValidator; use json::JSONValidator; use serde::de::Deserialize; use crate::{ ast::{ GroupChoice, GroupEntry, GroupRule, Identifier, Occur, Rule, Type, Type2, TypeChoice, TypeRule, CDDL, }, cd...
true
3ccf51fa584811cb8472f3527dfb9d6a9916c0f4
Rust
drocco007/tr
/tests/black_box.rs
UTF-8
3,535
3.234375
3
[]
no_license
use std::io::Cursor; use tr::command::tr; fn _tr<A>(args: A, stdin: &str) -> String where A: IntoIterator, A::Item: AsRef<str> { let stdin = Cursor::new(stdin); let mut stdout = Vec::new(); tr(args, stdin, &mut stdout); String::from_utf8(stdout).expect("Not UTF-8") } #[test] fn should_sa...
true
85afc4f2c47ee6c33ba2785662e1bcc21d837045
Rust
dunstontc/learn-rust
/code/TheBookV2/CommonCollections/strangs/src/main.rs
UTF-8
1,304
3.65625
4
[]
no_license
fn main() { let mut a = String::new(); a.push_str("pushed contents"); let data = "initial contents"; let b = data.to_string(); // the method also works on a literal directly: let c = "initial contents".to_string(); let d = String::from("initial contents"); let mut e = String::from("l...
true
43d0723165d66299ecd0fa810fc7a12a62b42a2d
Rust
dora-gt/interledger-rs
/crates/interledger-router/src/router.rs
UTF-8
14,118
2.875
3
[ "Apache-2.0" ]
permissive
use super::RouterStore; use bytes::Bytes; use futures::{future::err, Future}; use interledger_packet::{ErrorCode, RejectBuilder}; use interledger_service::*; use log::{error, trace}; use std::str; /// # Interledger Router /// /// The `Router` implements an incoming service and includes an outgoing service. /// It dete...
true
8d8cf9b10beaa27376f7e55e4a751285205a5f06
Rust
NoSequel/readme_gen
/src/data.rs
UTF-8
2,521
3.0625
3
[]
no_license
use serde::*; use std::fs; use std::fs::File; use std::path::Path; use std::io::prelude::*; #[derive(Deserialize, Serialize, Clone)] pub struct Settings { pub header: String, pub experiences: Vec<Experience>, pub projects: Vec<Project>, pub stats_url: String } #[derive(Deserialize, Serialize, Clone...
true
5002f81dc02a2c6e739c5d8ba4d404790829164f
Rust
silven/testing-actors
/src/main.rs
UTF-8
2,284
3.09375
3
[]
no_license
extern crate actix; extern crate futures; use actix::prelude::*; use futures::{future, Future}; struct Fib(usize); impl Message for Fib { type Result = Result<usize, ()>; } struct FibVec(usize); impl Message for FibVec { type Result = Result<Vec<usize>, ()>; } struct Fibber(); impl Actor for Fibber { ...
true
d38e2fc88cbd2bcca4b6dabd05cea4ff0cb73513
Rust
masonk/advent2017
/src/14/14.rs
UTF-8
11,350
3.40625
3
[]
no_license
// --- Day 14: Disk Defragmentation --- // Suddenly, a scheduled job activates the system's disk defragmenter. Were the situation different, you might sit and watch it for a while, but today, you just don't have that kind of time. It's soaking up valuable system resources that are needed elsewhere, and so the only opt...
true
afe0d75e69312bb032fb0bbf491e513a67d18fe1
Rust
zheland/custom-print
/src/macros/panic_hook.rs
UTF-8
4,772
3.25
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
/// Defines `panic_hook` function that can be used as panic hook that uses the specified writer. /// /// The first argument specify function name in the format `fn FUNC_NAME(...)` /// and can be omitted to use the default name `panic_hook`. /// /// # Examples /// #[cfg_attr(feature = "alloc", doc = "```rust")] #[cfg_at...
true
62078c7076f54dc2b1351229f4767f2f85e66f50
Rust
bwhetherington/rust-lisp
/src/environment.rs
UTF-8
1,206
3.34375
3
[]
no_license
use std::collections::HashMap; use values::Value; pub struct Environment { stack: Vec<HashMap<String, Value>> } impl Environment { pub fn new() -> Environment { let mut env = Environment { stack: vec![] }; env.enter_scope(); env } fn cur_scope(&self) -> &Ha...
true
8356b723acc70426f3bfd40f7785e9de89237543
Rust
BitcoinUnlimited/ElectrsCash
/src/wstcp/server.rs
UTF-8
1,726
2.8125
3
[ "MIT" ]
permissive
use crate::errors::*; use crate::wstcp::channel::ProxyChannel; use async_std::net::TcpListener; use std::net::SocketAddr; /// WebSocket to TCP proxy server. #[derive(Debug)] pub struct ProxyServer { real_server_addr: SocketAddr, listener: TcpListener, } impl ProxyServer { /// Makes a new `ProxyServer` inst...
true
0f539de1e886c9cc6c2284a09967f580e5c42544
Rust
Icey1717/SushiGoNN
/src/neural_network_game/neural_network.rs
UTF-8
8,978
3.0625
3
[ "MIT" ]
permissive
use rulinalg::matrix::{Matrix, BaseMatrixMut}; use rand::Rng; use std::error::Error; use std::io::prelude::*; use std::fs::File; use std::path::Path; const MUTATE_AMOUNT: f32 = 0.01; #[derive(Clone)] #[derive(Serialize, Deserialize)] pub struct NeuralNetworkProperties { // A vector of inputs relating to which ca...
true
fcd0540b74788d998fe454e4e3afb845fcaccfdc
Rust
snapview/tungstenite-rs
/examples/autobahn-client.rs
UTF-8
1,445
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
use log::*; use url::Url; use tungstenite::{connect, Error, Message, Result}; const AGENT: &str = "Tungstenite"; fn get_case_count() -> Result<u32> { let (mut socket, _) = connect(Url::parse("ws://localhost:9001/getCaseCount").unwrap())?; let msg = socket.read()?; socket.close(None)?; Ok(msg.into_tex...
true
50fb742a7e56173cab86ad4e3907b9dede4b2eae
Rust
charpercyr/chos
/lib/chos-lib/src/sync/fake.rs
UTF-8
848
2.8125
3
[]
no_license
use super::lock::{RawLock, RawTryLock}; use super::rwlock::{RawRWLock, RawTryRWLock}; pub struct FakeLock(()); impl FakeLock { pub const unsafe fn new() -> Self { Self(()) } } unsafe impl RawLock for FakeLock { fn lock(&self) { // Nothing } unsafe fn unlock(&self) { // Not...
true
f4525f60dbed78b021c669c9e65f8ec0c05b4f0c
Rust
noobLue/tmc-langs-rust
/tmc-langs/src/data.rs
UTF-8
5,566
3.46875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Various data types. use schemars::JsonSchema; use serde::Serialize; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::{collections::HashMap, path::PathBuf}; use tmc_client::{CourseData, CourseDetails, CourseExercise}; use crate::error::{LangsError, ParamError}; /// Exercise inside the projects di...
true
ae4ec011bf4f28d25b388cfb78e75c2ad2ec2b04
Rust
yhakbar/ya
/src/cli/yadayada.rs
UTF-8
2,894
3.109375
3
[ "MIT" ]
permissive
use clap::{Parser, Subcommand}; use std::path::PathBuf; #[derive(Subcommand)] pub enum TemplateSubcommand { /// List templates. #[command(about, alias = "ls")] List { /// The templates directory to list. #[arg(short, long)] dir: Option<PathBuf>, }, /// Stamp a saved templ...
true
3700cd8019ba17731e96f16294f954c8be52b0fd
Rust
naps62/rgba
/src/display/render_thread.rs
UTF-8
2,170
2.703125
3
[]
no_license
extern crate gfx_graphics; extern crate piston; extern crate piston_window; extern crate texture; use crossbeam_channel::Sender; use piston::{Button, Event}; use piston_window::{PistonWindow, Texture}; use std::{sync::Arc, thread}; use crate::buffer::Buffer; use crate::input::KeyEvent; pub fn spawn( width: f64, ...
true
353f32e2379f6b17264ddf6c670281fc109b63b2
Rust
achanda/probability
/benches/distribution/binomial.rs
UTF-8
929
2.53125
3
[ "MIT" ]
permissive
use probability::prelude::*; use test::{Bencher, black_box}; #[bench] fn cdf(bencher: &mut Bencher) { let d = Binomial::new(100_000, 0.845); let x = Independent(&d, &mut random::default()).take(1000).collect::<Vec<_>>(); bencher.iter(|| black_box(x.iter().map(|&x| d.cdf(x as f64)).collect::<Vec<_>>())); }...
true
64e60c2338bda0b774c3364f8c4575d2458548c5
Rust
acshi/jlrs
/jlrs/src/wrappers/ptr/array/data/inline.rs
UTF-8
11,827
3.1875
3
[ "MIT" ]
permissive
//! Inline array data borrowed from Julia. use crate::{ memory::frame::Frame, private::Private, wrappers::ptr::{ array::{ dimensions::{ArrayDimensions, Dims}, Array, }, private::Wrapper, }, }; use jl_sys::jl_array_data; use std::{ marker::PhantomData,...
true
9e71b3cc3e6f3260f25a7b178f57f6736b76b989
Rust
randomPoison/cs-bindgen
/cs-bindgen-macro/src/enumeration.rs
UTF-8
15,789
2.515625
3
[]
no_license
use crate::{ describe_named_type, impl_named, quote_convert_list_fn, quote_index_fn, quote_vec_drop_fn, reject_generics, repr_impl, value, BindingStyle, }; use proc_macro2::{Literal, TokenStream}; use quote::*; use syn::*; pub fn quote_enum_item(item: ItemEnum) -> syn::Result<TokenStream> { reject_generics...
true
ba9cb9208ac96eb2c056904154c91958ff1a2b3b
Rust
mozilla/gecko-dev
/third_party/rust/wasmparser/src/parser.rs
UTF-8
62,795
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "Apache-2.0" ]
permissive
use crate::binary_reader::WASM_MAGIC_NUMBER; use crate::CoreTypeSectionReader; use crate::{ limits::MAX_WASM_MODULE_SIZE, BinaryReader, BinaryReaderError, ComponentCanonicalSectionReader, ComponentExportSectionReader, ComponentImportSectionReader, ComponentInstanceSectionReader, ComponentStartFunction, Comp...
true
c63855850f599d9adae6d7a949b41fca21323923
Rust
RedEyedMars/AutoClaw
/src/game/entities/mod.rs
UTF-8
5,111
2.796875
3
[]
no_license
use crate::game::{Event, Events, Idable}; use crate::gui::animation::img::Img; use std::collections::hash_map::{Entry, HashMap}; use std::collections::HashSet; use generational_arena::{Arena, Index}; pub mod combat; pub mod factions; pub mod items; pub mod skills; pub mod stats; pub mod traits; #[derive(Clone, Copy)...
true
57d88c1e9239395d6a36f02e36a103669cdea245
Rust
loicngr/Square-Game
/src/entity/mod.rs
UTF-8
6,942
3.375
3
[ "MIT" ]
permissive
use sdl2::render::WindowCanvas; use crate::{COLOR_BACKGROUND}; use sdl2::rect::Rect; use sdl2::pixels::Color; use rand::Rng; // Entity direction enumeration #[derive(Debug)] pub enum EntityDirection { Idle, Up, Down, Left, Right } // Entity location structure #[derive(Debug, Clone)] pub struct Ent...
true
98a3b39cbbefafeb28ec62571bbf58da1ef6ea0f
Rust
finnbear/ARTificial_Intelligence
/src/generate.rs
UTF-8
37,021
2.578125
3
[ "Unlicense" ]
permissive
mod common; use crossbeam::thread; use image; use image::imageops; use imageproc; use imageproc::drawing::Canvas; use imageproc::rect::Rect; use palette; use palette::IntoColor; use rand; use rand::{ distributions::{Distribution, Standard}, Rng, }; use serde::{Deserialize, Serialize}; use serde_yaml; use std::f...
true
747cb2937986190138e654a801258b5f23d1f73d
Rust
udzura/octocrab
/src/api/orgs.rs
UTF-8
4,402
3
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! The Organization API. mod list_repos; use crate::Octocrab; pub use self::list_repos::ListReposBuilder; /// A client to GitHub's organization API. /// /// Created with [`Octocrab::orgs`]. pub struct OrgHandler<'octo> { crab: &'octo Octocrab, owner: String, } impl<'octo> OrgHandler<'octo> { pub(crate...
true
9a5a8bd8187fce183c3fd7c962d4f9dadb5ca2e3
Rust
arizuk/programming-contest-solutions
/codeforces/1175/C/brute.rs
UTF-8
1,843
3.109375
3
[]
no_license
#[allow(unused_macros)] macro_rules! debug { ($($a:expr),*) => { #[cfg(debug_assertions)] writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*); } } #[allow(unused_imports)] use std::cmp::{min, max}; #[allow(unused_imports)] use std::io::Write; fn get_k...
true
afe0d7b6d0afe5fc210f7e141b1ef9e2393c8864
Rust
mcastorina/repost
/src/db/db.rs
UTF-8
5,606
2.9375
3
[]
no_license
use super::{InputOption, OutputOption, Request, RequestResponse, Variable}; use crate::error::Result; use comfy_table::Cell; use rusqlite::{Connection, NO_PARAMS}; use std::collections::HashMap; use std::collections::HashSet; use std::fs; use std::iter::FromIterator; use std::path::{Path, PathBuf}; pub struct Db { ...
true
ed4e14a7d57ceca25b13537031034a5d8124349f
Rust
iCodeIN/rust-nes-emulator
/src/smb_level.rs
UTF-8
13,402
2.5625
3
[]
no_license
use nes::*; use ines::lines_from_file; use std::collections::HashMap; use phf::Map; use level_consts::*; const NO_GROUP: u8 = 0xFF; const GROUPABLE: Map<u8, (u8, u8)> = phf_map!{ 0x20u8 => (0x20, 0x50), 0x30u8 => (0x30, 0x60), 0x40u8 => (0x40, NO_GROUP), 0x70u8 => (NO_GROUP, 0x70), 0x10u8 => (0x10...
true
152b4ade8c331745d373ec8d58be51ae53364bae
Rust
karoberts/adventofcode2015
/rust/src/day14.rs
UTF-8
2,127
2.96875
3
[]
no_license
use regex::Regex; use super::utils; enum Current { Fly, Rest } struct Deer { speed: i32, flytime: i32, resttime: i32, dist: i32, cur: Current, fstart: i32, rstart: i32, flight: i32, points: i32 } pub fn _run() { let re = Regex::new(r"^([A-Za-z]+) can fly (\d+) km/s f...
true
70f20ab807ed4e42e8958d1425e0f357ab889597
Rust
vincentdephily/mqttrs
/src/lib.rs
UTF-8
2,583
3
3
[ "Apache-2.0" ]
permissive
//! `mqttrs` is a codec for the MQTT protocol. //! //! The API aims to be straightforward and composable, usable with plain `std` or with a framework //! like [tokio]. The decoded packet is help in a [Packet] struct, and the encoded bytes in a //! [bytes::BytesMut] struct. Convert between the two using [encode()] and [...
true
111dec49a0f39842cd0932b192982d8837a224e0
Rust
bsorin/sendgrid-rs
/src/sg_client/mod.rs
UTF-8
3,892
2.65625
3
[ "MIT" ]
permissive
use mail::Mail; use std::borrow::Cow; use std::io::Read; use hyper::Client; use hyper::error::Error; use hyper::header::{Authorization, Bearer, ContentType, Headers, UserAgent}; use hyper::mime::{Mime, TopLevel, SubLevel}; static API_URL: &'static str = "https://api.sendgrid.com/api/mail.send.json?"; /// This is th...
true
d125bea7f4f2f534887e4a33147560a763643e69
Rust
denoland/deno
/cli/util/time.rs
UTF-8
858
2.515625
3
[ "MIT" ]
permissive
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. /// Identical to chrono::Utc::now() but without the system "clock" /// feature flag. /// /// The "clock" feature flag pulls in the "iana-time-zone" crate /// which links to macOS's "CoreFoundation" framework which increases /// startup time for...
true
268856a3747df452498f6b0f4abee8acb988ab86
Rust
sugyan/leetcode
/others/february-leetcoding-challenge-2021/week-2/3634/lib.rs
UTF-8
2,330
3.53125
4
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use utils::TreeNode; pub struct Solution; impl Solution { pub fn convert_bst(root: Option<Rc<RefCell<TreeNode>>>) -> Option<Rc<RefCell<TreeNode>>> { let mut greater = 0; Self::dfs(&root, &mut greater) } fn dfs( node: &Option<Rc<RefCell<TreeN...
true
47a29427d2a440b1a389f1e832c29f744a56e2a5
Rust
robjtede/async-graphql
/src/types/any.rs
UTF-8
1,497
3.15625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{InputValueResult, Scalar, ScalarType, Value}; use serde::de::DeserializeOwned; /// Any scalar (For [Apollo Federation](https://www.apollographql.com/docs/apollo-server/federation/introduction)) /// /// The `Any` scalar is used to pass representations of entities from external services into the root `_entit...
true
5bb4973a51d2c0586963f82a450d33590dc3cced
Rust
garciparedes/advent-of-code
/2015/03_perfectly_spherical_houses_in_a_vacuum_part_1.rs
UTF-8
834
2.984375
3
[ "Apache-2.0" ]
permissive
use std::io; use std::io::prelude::*; use std::collections::HashSet; fn main() -> io::Result<()> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; let mut current = (0, 0); let mut visited: HashSet<(isize, isize)> = vec![current].into_iter().collect(); for direction in b...
true
c94c123928cba4e8ee56bce26907b3d4a68e5fed
Rust
indykish/popsicle
/gtk/src/image.rs
UTF-8
2,265
3.265625
3
[ "MIT" ]
permissive
use popsicle::Image; use std::io; use std::path::{Path, PathBuf}; use std::sync::Mutex; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::Receiver; /// A structure for buffering disk images in the background. pub struct BufferingData { /// Stores the path of the image, and the image contents sto...
true
3ebbb166f0a17e51eca08b9d5d9326889701f03e
Rust
gskapka/ethereum-receipt-proof-maker
/src/get_rpc_call_jsons.rs
UTF-8
2,482
3.09375
3
[ "MIT" ]
permissive
use crate::types::Result; use serde_json::Value; pub fn get_block_by_block_hash_json(block_hash: String) -> Result<Value> { Ok(json!({ "id": "1", "jsonrpc": "2.0", "method": "eth_getBlockByHash", "params": [ block_hash, false ], })) } pub fn get_block_by_block_number_json(block...
true
a4c49d36b1bd610daf656e87a213c7a5b3742e86
Rust
daniel-tp/ffmpeg-decoder-rs
/cli/src/main.rs
UTF-8
1,926
2.765625
3
[ "MIT" ]
permissive
use anyhow::Error; use env_logger::Env; use log::{error, info}; use structopt::StructOpt; use rodio::Sink; use std::path::PathBuf; fn main() { env_logger::from_env(Env::default().default_filter_or("info")).init(); let opts = Opts::from_args(); let status = match opts.command { Command::Convert ...
true
ee21e6212f67280a531d307336dc025b3ee76db1
Rust
ConstantineGochev/text-aggregator
/src/extentions.rs
UTF-8
251
3.125
3
[]
no_license
pub type Range<'r> = (&'r str, &'r str); pub trait IsValid { fn is_valid(&self) -> bool; } impl<'r> IsValid for Range<'r> { fn is_valid(&self) -> bool { let (start, end) = &self; !start.is_empty() && !end.is_empty() } }
true
36186eb8ade585a88c71028902773d3573891ccd
Rust
Sroka/arc_level_generator
/src/generator/calculate_feature_shift.rs
UTF-8
5,923
2.75
3
[ "MIT" ]
permissive
use rand::{RngCore, Rng}; use crate::generator::types::{VisibleWorld, Feature}; use nalgebra::{Vector3}; use crate::generator::calculate_prefabs_spawn_bounds::{calculate_prefabs_spawn_bounds}; /// Randomizes a shift with which all the entities belonging to this feature will be spawned. This /// function makes sure tha...
true
a86945927296c2cd294c0279c591d9d268906c12
Rust
caibirdme/leetcode_rust
/src/prob_583.rs
UTF-8
1,411
3.421875
3
[ "MIT" ]
permissive
use std::cmp::max; impl Solution { pub fn min_distance(word1: String, word2: String) -> i32 { if word1.is_empty() { return word2.len() as i32; } if word2.is_empty() { return word1.len() as i32; } if word1.len() < word2.len() { return Self:...
true
e5d83a59ada6477c718d684aabc2da3c100d3f77
Rust
elsuizo/abstreet
/game/src/debug/polygons.rs
UTF-8
7,698
2.671875
3
[ "Apache-2.0" ]
permissive
use crate::game::{State, Transition}; use crate::helpers::ID; use crate::render::calculate_corners; use crate::ui::UI; use abstutil::Timer; use ezgui::{EventCtx, GfxCtx, Key, Line, Text, WarpingItemSlider}; use geom::{Polygon, Pt2D, Triangle}; pub struct PolygonDebugger { slider: WarpingItemSlider<Item>, cente...
true
b00a67e066b9ae521f589b57c77682dba32a2355
Rust
kpp/test_ocl
/src/main.rs
UTF-8
1,754
2.5625
3
[]
no_license
pub static DIFF_SPACE_SRC: &'static str = r#" typedef struct { long2 input_ones; long2 input_zeros; } Cluster; typedef struct { Cluster clusters[10]; } Point; kernel void add_idx(global Point* in_points) { uint const idx = get_global_id(0); global Point* const point = &in_points[idx]; for (uin...
true
62e8ed401fcbbb03eb1392d2e3e1958ebdd3f458
Rust
iyzana/bollard
/src/system.rs
UTF-8
8,749
2.765625
3
[ "Apache-2.0" ]
permissive
//! System API: interface for interacting with the Docker server and/or Registry. use arrayvec::ArrayVec; use chrono::serde::{ts_nanoseconds, ts_seconds}; use chrono::{DateTime, Utc}; use futures_core::Stream; use http::request::Builder; use hyper::{Body, Method}; use std::collections::HashMap; use std::hash::Hash; ...
true
d52b8ecb8b451c68b7414d07e9ac56ed18e5cabe
Rust
bagusn13/medium-exercism-rust
/clock/src/lib.rs
UTF-8
2,390
3.828125
4
[]
no_license
use std::fmt; pub struct Clock{ hours: i32, minutes: i32, } impl Clock { pub fn new(hours: i32, minutes: i32) -> Self { //convert ke menit semua //untuk yang minus //-45 -> 23:15 //waktu dalam sehari + (-45) //1440 - 45 = 1395 //23 : 15 //...
true
e0a0b07faf9da16c9c374c89c2bab85b8fd4df10
Rust
Tsuyoshi-Iwanaga/learning_rust
/005/struct.rs
UTF-8
718
3.625
4
[]
no_license
//構造体は中に複数をフィールドをもつ //CやC++の構造体とは異なりメソッドを持つことができるためクラスに近い struct Member { id: String, name: String, age: i32, } fn main() { let m = Member { id: String::from("A0101"), name: String::from("Pochi"), age: 12, }; println!("id: {}", m.id); println!("name: {}", m.name); println!("age: {}", m.age...
true
fda2341156b0ee589a0675ed8f01d82b5fa1f289
Rust
ttappr/blueshift-gfx
/src/memory.rs
UTF-8
4,837
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::any::Any; use std::error::Error; use std::fmt; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; //use web_sys::{Request, RequestInit, RequestMode, Response}; use js_sys::ArrayBuffer; use js_sys::Object; use js_sys::TypeError; use web_sys::Blob; use web_sys::console...
true
38e3a17ed4b9959656f50a4568e8168e6015e813
Rust
mjedwabn/aoc2020
/day8/src/lib.rs
UTF-8
4,671
3.125
3
[]
no_license
pub mod day8 { use std::collections::HashMap; use std::io::BufRead; pub fn run_boot_code(input: &mut dyn BufRead) -> i32 { let mut console = GameConsole::new(parse_instructions(input)); console.run_boot_code(); return console.get_accumulator(); } pub fn fix_boot_code(input:...
true
41016e68e8461b3310835eea07251fec09f7c0df
Rust
utkarshkukreti/munch.rs
/benches/examples.rs
UTF-8
2,235
2.578125
3
[]
no_license
use criterion::{black_box, Criterion, Throughput}; #[path = "../examples/arithmetic.rs"] mod arithmetic; #[path = "../examples/clojure.rs"] mod clojure; #[path = "../examples/ini.rs"] mod ini; #[path = "../examples/ip.rs"] mod ip; fn bench_arithmetic_example(c: &mut Criterion) { let mut group = c.benchmark_gro...
true
378d1049e96897f539eb2dc7806e08a9bf63a45a
Rust
rust-syndication/rss
/src/extension/itunes/itunes_owner.rs
UTF-8
3,932
2.765625
3
[ "Apache-2.0", "MIT" ]
permissive
// This file is part of rss. // // Copyright © 2015-2021 The rust-syndication Developers // // This program is free software; you can redistribute it and/or modify // it under the terms of the MIT License and/or Apache 2.0 License. use std::io::Write; use quick_xml::events::{BytesEnd, BytesStart, Event}; use quick_xm...
true
dabcae35a415fd6316e7431a06c0b8e59aff8e96
Rust
TeXitoi/structopt
/examples/enum_in_args.rs
UTF-8
865
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! How to use `arg_enum!` with `StructOpt`. //! //! Running this example with --help prints this message: //! ----------------------------------------------------- //! structopt 0.3.25 //! //! USAGE: //! enum_in_args <i> //! //! FLAGS: //! -h, --help Prints help information //! -V, --version Print...
true
6525c5597f2bd447f25357bae97adcdab5b8e8ee
Rust
brettcannon/python-launcher
/tests/lib_system_tests.rs
UTF-8
1,432
2.515625
3
[ "MIT" ]
permissive
mod common; use serial_test::serial; use python_launcher::{ExactVersion, RequestedVersion}; use common::EnvState; #[test] #[serial] fn all_executables() { let env_state = EnvState::new(); let executables = python_launcher::all_executables(); assert_eq!(executables.len(), 3); let python27_version ...
true
396c9ceb089f1dcd71fd7abfeb6a589d2b8f26ed
Rust
forkkit/tapdance
/tapdance-rust-logic/src/protocol_outer_framing.rs
UTF-8
25,747
2.65625
3
[ "Apache-2.0" ]
permissive
use std::mem; use protobuf; use session_error::SessionError; use signalling::ClientToStation; use stream_traits::{ReadStat, StreamReceiver}; // This file is the reading half of the station's implementation of the outer // framing protocol. The outer framing protocol (type+len followed by blob) is // never supposed t...
true
5099b7ffa99e37c2e510cfb1577b3b5f0cf4934a
Rust
frcl/nbody
/src/vec.rs
UTF-8
2,403
3.671875
4
[]
no_license
use serde::{Serialize, Deserialize}; use std::ops::{Add, Sub, Mul, AddAssign, SubAssign}; use std::iter::Sum; use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] pub struct Vec2(f64, f64); impl Vec2 { pub fn new(x: f64, y: f64) -> Vec2 { Vec2(x, y) } pub fn norm(&self...
true
321409c53e227bbb230d95a93c94323708d0bad9
Rust
tadas-subonis/kuhn_vanilla_cfr
/src/main.rs
UTF-8
7,465
2.765625
3
[]
no_license
#[macro_use] extern crate ndarray; use itertools::Itertools; use std::collections::HashMap; use ndarray::prelude::*; const _N_ACTIONS: i16 = 2; const _N_CARDS: i16 = 3; fn is_chance_node(history: &str) -> bool { history == "" } fn is_terminal(history: &str) -> bool { match history { "rrcc" => true,...
true
aecc61d900bcf67f1d308e0b178d4cadfacfd201
Rust
mitsuhiko/aoc19
/aoc10/src/main.rs
UTF-8
2,004
3.15625
3
[]
no_license
use std::collections::{BTreeMap, BTreeSet}; use std::f64::consts::PI; const PRECISION: f64 = 100_000.0; type Point = (i64, i64); fn parse_asteroids(data: &str) -> Vec<Point> { data.trim() .lines() .enumerate() .flat_map(|(y, line)| { line.chars() .enumerate() ...
true
a1d50198166a13b980d37587cf89ff2e9b079c53
Rust
M-Blomqvist/raytracer
/src/bin.rs
UTF-8
1,641
2.59375
3
[]
no_license
use image::Rgb; use raytracer::{scene::*, view::*}; fn main() { let view = View::new( 1920, 1080, [0.0, 0.0, 0.0], //no other positions supported w/ reflections gauranteed 90.0, [0.0, 0.0, 1.0], 12, Rgb([50, 100, 200]), 1e-3, ); let mut scene ...
true
2f96b3aa12adc9e53e4db948403e06470a9ef41a
Rust
greyblake/whatlang-rs
/src/dev.rs
UTF-8
2,851
2.75
3
[ "MIT" ]
permissive
//! This mod exposes some internal API. //! It exists only to enable tuning of the library with extra supporting tools (e.g. benchmarks). //! Developers are advised against relying on API. //! pub use crate::alphabets::{raw_detect as alphabets_raw_detect, RawOutcome as RawAlphabetsInfo}; pub use crate::combined::{raw_d...
true
8f48b87fea14c6029b81b05428fb1e6c7be15cdd
Rust
zeebonk/aoc18
/src/day_01.rs
UTF-8
1,677
3.296875
3
[]
no_license
mod shared; use shared::{output_and_time}; use std::collections::HashSet; const INPUT: &str = include_str!("../input/day_01.txt"); fn main() { output_and_time("Part 1", || Box::new(solve_part_1(INPUT))); output_and_time("Part 2", || Box::new(solve_part_2(INPUT))); } fn solve_part_1(input: &str) -> i32 { ...
true
5daf84142519f639bc2d8b95c93948713858a5db
Rust
Connicpu/math2d
/src/recti.rs
UTF-8
6,447
3.296875
3
[ "MIT" ]
permissive
//! Axis-aligned rectangle defined by the lines of its 4 edges. use crate::point2i::Point2i; use crate::rectf::Rectf; use crate::rectu::Rectu; #[cfg(all(windows, feature = "d2d"))] use winapi::um::dcommon::D2D_RECT_L; #[cfg(all(windows, feature = "d2d"))] use winapi::um::wincodec::WICRect; /// Represents a rectangle...
true
c82733a8b99f5416f94220ff6a72fd8269c753db
Rust
guydunton/rust-gb
/src/gameboy/tests/push_pop_test.rs
UTF-8
2,510
3.421875
3
[]
no_license
use crate::gameboy::opcodes::Argument; use crate::gameboy::opcodes::Category; use crate::gameboy::tests::decode_util::decode; use crate::gameboy::Gameboy; use crate::gameboy::OpCode; use crate::gameboy::RegisterLabel16; #[test] fn pop_instruction_moves_the_stack_pointer() { // POP BC. The test has space then the ...
true
48c5a735afb17b6081474145ada91ae96e4bfb38
Rust
MegatonHammer/megaton-hammer
/megaton-hammer/src/tls.rs
UTF-8
5,074
3.1875
3
[]
no_license
//! Thread Local Storage //! //! On the switch, every thread is given a thread-specific IPC buffer, and a //! pointer that the userland can use however they see fit. This is some kind of //! global state, and as we all know, Rust hates global state. This module //! provides a safe wrapper around the TLS structure. //! ...
true
3d0ac47f00d4ff5009bb932c9ad86cca0e69c21b
Rust
villhei/vgtk-todomvc
/src/todo/filter.rs
UTF-8
1,462
2.578125
3
[]
no_license
use vgtk::lib::gtk::*; use vgtk::{gtk, Component, Callback, UpdateAction, VNode}; use super::model::{TaskFilter}; #[derive(Clone, Debug, Default)] pub struct Filter { pub filters: &'static [(&'static str, TaskFilter)], pub active: TaskFilter, pub on_changed: Callback<TaskFilter>, } impl PartialEq for ...
true
79c021e821491a20ba2ce33beab667f7bb85db29
Rust
toyboot4e/anf
/crates/anf_gfx/texture/sprite.rs
UTF-8
2,873
3.15625
3
[ "MIT" ]
permissive
pub use crate::texture::texture::{TextureData2d, TextureKind}; use fna3h::Color; use crate::geom2d::*; /// Conversion impl TextureData2d { pub fn trim_px(&self, rect: impl Into<[u32; 4]>) -> SubTextureData2d { let rect = rect.into(); let uv_rect = [ rect[0] as f32 / self.w as f32, ...
true
334aa4ae9d6ccaedbc2b21db341cb50a8c5145d2
Rust
BruceBrown/rust-minesweeper
/src/media_layer.rs
UTF-8
4,199
3.296875
3
[ "MIT" ]
permissive
use std::borrow::Borrow; use std::cell::{Cell, RefCell}; use std::collections::HashMap; use std::hash::Hash; use std::rc::Rc; pub struct ImageContainer<T> { pub raw_bytes: Option<&'static [u8]>, pub image_data: Cell<Option<T>>, } impl<T> ImageContainer<T> { pub fn raw_bytes(&self) -> Option<&'static [u8]>...
true
bed8d1536a6f5ac25e7e57e9599e3f45eec6b225
Rust
agentcooper/advent-of-code-2018
/src/01/main.rs
UTF-8
765
2.984375
3
[]
no_license
use std::collections::HashSet; static INPUT: &str = include_str!("input.txt"); fn part1() -> i32 { return INPUT.lines().fold(0, |sum, line| { let n = line .parse::<i32>() .unwrap_or_else(|e| panic!("{}: {}", line, e)); return n + sum; }); } fn part2() -> i32 { let mut score = HashSet::new(...
true
bc8bcfa061705f4dbc7f910a76a078c17bb4f2c5
Rust
evq/embedded-graphics
/embedded-graphics/benches/fonts.rs
UTF-8
686
2.59375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use criterion::*; use embedded_graphics::{ fonts::{Font12x16, Font6x8}, prelude::*, }; fn font_6x8(c: &mut Criterion) { c.bench_function("font 6x8 Hello world!", |b| { let object: Font6x8<u8> = Font6x8::render_str("Hello world!").stroke(Some(10)); b.iter(|| object.into_iter().collect::<Vec...
true
f97354a791bb078072d9f82bb1afa755e860f1b8
Rust
neosmart/prettysize-rs
/src/fmt.rs
UTF-8
20,688
3.75
4
[ "MIT" ]
permissive
//! The `fmt` module contains [`SizeFormatter`] and other types pertaining to formatting a size as //! human-readable text. //! //! You will likely not need to interact with this module directly, as the functionality of a //! [`SizeFormatter`] is exposed by simply calling [`Size::format()`]. However, a new //! [`SizeFo...
true
a8cd579aff590916bec9409dc3239b6cf9e2e362
Rust
Nemo157/gamelike.rs
/src/event.rs
UTF-8
1,951
2.890625
3
[]
no_license
extern crate glutin; use glutin::Event::{ Closed, KeyboardInput, MouseMoved }; use glutin::ElementState::{ Pressed, Released }; use glutin::VirtualKeyCode as Key; use camera::{ Action, Direction }; use camera::Action::{ Start, Stop }; use camera::Direction::{ Left, Forward, Right, Back, Up, Down }; use self::Event::...
true
fc8912814de8ade50f247820749dc1d1848cbe33
Rust
megalphian/AdventOfCode2019
/src/day1.rs
UTF-8
842
3.15625
3
[]
no_license
use std::fs; fn calculate_fuel( mass : i32) -> i32 { (mass/3 - 2) } fn main() { let filename = "data/input1.txt"; let mut _part_1_total_fuel : i32 = 0; let mut _part_2_total_fuel : i32 = 0; let _file_contents = fs::read_to_string(filename) .expect("Something went wrong reading the file"); ...
true
f3103abe911e2a657d4b18e25bcc095faf7c6dc0
Rust
philbooth/fancy-regex
/tests/captures.rs
UTF-8
3,023
3.15625
3
[ "MIT" ]
permissive
use fancy_regex::{Captures, Match, Result}; mod common; #[test] fn captures_fancy() { let captures = captures(r"\s*(\w+)(?=\.)", "foo bar."); assert_eq!(captures.len(), 2); assert_match(captures.get(0), " bar", 3, 7); assert_match(captures.get(1), "bar", 4, 7); assert!(captures.get(2).is_none()); ...
true
39f8a284b3de452afd80206664155da455d3df45
Rust
sudaraka/learn-rust-rest-elm
/src/server/models.rs
UTF-8
1,878
2.859375
3
[]
no_license
use diesel; use diesel::prelude::*; use schema::book; use schema::book::dsl::{self, book as all_books}; #[derive(Queryable, Serialize)] pub struct Book { pub id: i32, pub title: String, pub author: String, pub published: bool, } #[derive(Insertable, Deserialize)] #[table_name = "book"] pub struct NewB...
true
62caf3aff3be94957c5ebb3f83f2adedf3665305
Rust
xlambein/rust-against-humanity
/back/src/main.rs
UTF-8
12,109
2.53125
3
[ "MIT" ]
permissive
use anyhow::{Result, bail}; use futures::{FutureExt, StreamExt}; use warp::Filter; use warp::ws::{Message, WebSocket}; use tokio::sync::{mpsc, RwLock}; use std::collections::{HashMap, hash_map}; use std::sync::{ Arc, atomic::{AtomicUsize, Ordering}, }; use rand::seq::IteratorRandom; use std::convert::Infallible; use...
true
c7ef9ead5f7bbf7f552ee1aa786bca4623c6418a
Rust
LinAGKar/advent-of-code-2017-rust
/day13a/src/main.rs
UTF-8
466
2.625
3
[ "MIT" ]
permissive
extern crate regex; use regex::Regex; use std::io; use std::io::Read; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let re = Regex::new(r"(?m)^(\d+): (\d+)$").unwrap(); println!("{}", re .captures_iter(&input) .map(|caps| (caps[1].parse::<i...
true
39e5f1cec06712f307b83a33970b4c3572489d59
Rust
resttime/shrimpray
/src/bvh.rs
UTF-8
3,900
2.84375
3
[ "MIT" ]
permissive
use std::sync::Arc; use crate::hit::Hittable; use crate::util::*; use crate::vec3::{Ray, Vec3}; pub struct AABB { _min: Vec3, _max: Vec3, } impl AABB { pub fn new(min: Vec3, max: Vec3) -> Self { Self { _min: min, _max: max, } } pub fn min(&self) -> Vec3 { ...
true
111bf5aeacd9ab3953a7caa0ce3c46c8192811a0
Rust
JacobVanGeffen/shuttle
/tests/basic/timeout.rs
UTF-8
1,907
3.078125
3
[ "Apache-2.0" ]
permissive
use shuttle::scheduler::{RandomScheduler, Schedule, Scheduler, TaskId}; use shuttle::sync::Mutex; use shuttle::Config; use shuttle::{thread, Runner}; use std::sync::Arc; use std::time::Duration; use test_env_log::test; /// A scheduler that sleeps between executions to test timeout behavior #[derive(Debug)] struct Slee...
true
204dc76e6bad293db5b0af20f3d62367cb8d0543
Rust
ubitux/pokanalysis
/extractor/src/tiling.rs
UTF-8
4,101
3.09375
3
[ "ISC" ]
permissive
use crate::{ image::{ BLOCK_LINESIZE, BLOCK_PIXELS_1D, BLOCK_SIZE, SPRITE_LINESIZE, SPRITE_PIXELS_1D, SPRITE_SIZE, TILE_LINESIZE, TILE_PIXELS_1D, }, sprites::{SPRITE7_LINESIZE, SPRITE7_SIZE}, }; /// Lay out a stream of 2D patches (`src)` onto a 2D surface (`dst`). /// /// The reflow operate...
true
041109b51c0c79eb20290be2bb4eadd51955548f
Rust
LukasKalbertodt/mauzi
/examples/modules/src/foo.mauzi.rs
UTF-8
78
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
unit greet(name: &str) { En => "Hi {name}!", De => "Hallo {name}!", }
true
6ab6e0414b31e07dee3cfcc01f3095810e629982
Rust
astro/rust-lpc43xx
/src/usb1/endptnaken/mod.rs
UTF-8
17,534
2.71875
3
[ "Apache-2.0" ]
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::ENDPTNAKEN { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
true
ace880b431eaec6b7359103f7186bcddad6a7b6f
Rust
ymt117/http-server
/Rust/http-server/src/main.rs
UTF-8
966
2.96875
3
[]
no_license
mod parser; mod response; use std::io::prelude::*; use std::net::TcpStream; use std::net::TcpListener; use std::thread; use std::io; use std::io::Read; fn handle_connection(mut stream: TcpStream) { const BUFFER_SIZE: usize = 1024; let mut buf = [0; BUFFER_SIZE]; stream.read(&mut buf).unwrap(); let req = parser::p...
true
2dfec384e2c4cc6755f05954dfcae8bfff54368b
Rust
RagePly/aoc16
/src/day9.rs
UTF-8
1,521
3.421875
3
[]
no_license
fn parse_repeat(slice: &str) -> usize { let closing = slice.find(")").unwrap(); let temp: Vec<_> = slice[..closing].split("x").map(|x: &str| -> usize { x.parse().unwrap() }).collect(); let nr_chrs: usize = temp[0]; let nr_times: usize = temp[1]; nr_chrs * nr_times + parse_text(&slice[(closing + 1 + ...
true
19e7c018c190777fc4ed45672a40dd79b424acfb
Rust
rcore-os-infohub/ossoc2020-shiweiwww-daily
/rbe/chapter8/src/main.rs
UTF-8
1,664
3.84375
4
[]
no_license
fn main() { // println!("Hello, world!"); // test1(); // test2(); // test3(); // test4(); test5(); } fn test1(){ let i=1; let j = if i<0 { 2 } else { 3 }; println!("i={},j={}",i,j); } fn test2(){ let mut count = 0; let i = loop{ count...
true
97be117770dcdb00a51c4752850ed3bb4825955f
Rust
slowmistio/MaskWalletCore
/interface/src/coins.rs
UTF-8
1,420
2.84375
3
[ "MIT" ]
permissive
use chain_common::api::Coin as CoinType; use chain_common::coin::Coin; use std::collections::HashMap; use std::string::ToString; lazy_static! { static ref COINS_MAP: HashMap<String, Coin> = { let coin_json = include_str!("../resource/coin.json"); let coins: Vec<Coin> = serde_json::from_str(coin_jso...
true
64e74f9489dbd2190f91beb77a33c9b1fc494d94
Rust
Byron/gitoxide
/gix-fs/src/lib.rs
UTF-8
2,751
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
//! A crate with file-system specific utilities. #![deny(rust_2018_idioms, missing_docs)] #![forbid(unsafe_code)] use std::path::PathBuf; /// Common knowledge about the worktree that is needed across most interactions with the work tree #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[de...
true
d73f47c95f3df8e5798990130568bbc5ae248a69
Rust
BurntSushi/aho-corasick
/src/util/prefilter.rs
UTF-8
30,533
3.03125
3
[ "Unlicense", "MIT" ]
permissive
use core::{ cmp, fmt::Debug, panic::{RefUnwindSafe, UnwindSafe}, u8, }; use alloc::{sync::Arc, vec, vec::Vec}; use crate::{ packed, util::{ alphabet::ByteSet, search::{Match, MatchKind, Span}, }, }; /// A prefilter for accelerating a search. /// /// This crate uses prefilt...
true
22f9c0953b54d1b14561f2300bf00ac7008b0416
Rust
isgasho/libwifi
/examples/capture_example/src/parse.rs
UTF-8
894
2.703125
3
[ "MIT" ]
permissive
use anyhow::Result; use pcap::Packet; use radiotap::Radiotap; pub fn handle_packet(packet: Packet) -> Result<()> { // At first, we look at the let radiotap = match Radiotap::from_bytes(packet.data) { Ok(radiotap) => radiotap, Err(error) => { println!( "Couldn't read ...
true
0d6a47c2945ab7a20c86582e997612e37552edfb
Rust
Rydgel/image-to-ascii
/src/ascii/output.rs
UTF-8
554
3.234375
3
[]
no_license
use ascii::AsciiString; use std::fs::File; use std::io::Write; use ascii::error::AsciiError; pub trait Output { fn save_on_disk(&self, output: &str) -> ::std::result::Result<String, AsciiError>; fn show_stdout(&self); } impl Output for AsciiString { fn save_on_disk(&self, output: &str) -> ::std::result::...
true
1985f1fd41fa2d357699a0cf8294673840f00291
Rust
cassLaffan/Rust
/x_and_o/src/main.rs
UTF-8
3,040
3.53125
4
[]
no_license
use std::io; use std::cmp::Ordering; fn set_playing_board(board: &[mut [mut i32, ..3], ..3], turn: i32) -> void{ if(turn == 0){ println!("_|_|_"); println!("_|_|_"); println!("_|_|_"); } else{ } } //this function will loop so long as a player's input is not valid fn ...
true
e6e5a78668928be85978f5e0572b923d3b60de14
Rust
marschium/quack
/src/parse/quack_struct.rs
UTF-8
4,548
2.765625
3
[]
no_license
use nom::character::complete::{one_of, alpha1, multispace0, digit1, line_ending, space0}; use nom::bytes::complete::tag; use nom::combinator::{map, map_res, opt}; use nom::branch::alt; use nom::multi::{separated_list}; use nom::sequence::{tuple, preceded, terminated, separated_pair}; use nom::error::VerboseError; use ...
true
05472403fea3e853691834a3210061e55d222b9c
Rust
hellodk/dumpyard
/rust_examples/variables/src/tuple1.rs
UTF-8
160
3.234375
3
[]
no_license
fn main() { let tup = (500, 6.4, 1); let (_x, _y, _z) = tup; println!("The value of y is: {}", _y); println!("The value of y is: {}", tup.2); }
true
6c3562d0941f4c43e25a0c4b817f69838a5513c6
Rust
redsnapper2006/leetcode-cn
/M/2317-maximum-xor-after-operations/main.rs
UTF-8
256
3.125
3
[]
no_license
struct Solution {} impl Solution { pub fn maximum_xor(nums: Vec<i32>) -> i32 { nums.into_iter().reduce(|acc, x| acc | x).unwrap() } } fn main() { println!( "{}", Solution::maximum_xor(vec![772, 45, 297, 549, 549, 301, 805, 297]) ); }
true