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
c22c0fff0e87367cb1173f9c9f1852e5959070b0
Rust
sriggin/pingcap-talent-plan
/src/bin/kvs.rs
UTF-8
2,212
2.9375
3
[]
no_license
#[macro_use] extern crate clap; #[macro_use] extern crate failure; use clap::{App, Arg, SubCommand}; fn main() -> kvs::Result<()> { let key_arg = Arg::with_name("key").required(true); let matches = App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crat...
true
e1e18dec6fdb5c243def558174b46b3ae5b7b093
Rust
evan-a-w/rustlib
/src/rope.rs
UTF-8
7,275
3.65625
4
[]
no_license
use std::rc::Rc; use std::fmt; use std::mem::{replace, MaybeUninit}; pub struct FString { rope: Rope } impl FString { pub fn new(s: String) -> Self { Self { rope: Rope::new(s), } } pub fn concat(&mut self, other: Self) { // We are switching self.rope with an uninit...
true
eaa9dc50b9c9f8208f58359ef5459fbb1c8cb7d5
Rust
NeoChow/rsbind
/tools-rsbind/src/config.rs
UTF-8
1,290
2.59375
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::Read; use std::path::PathBuf; use toml; #[derive(Clone, Deserialize, Debug)] pub struct Config { pub android: Option<Android>, pub ios: Option<Ios>, } #[derive(Clone, Deserialize, Debug)] pub struct Android { pub ndk_stand_alone: Option<String>, pub rustc_param: Option<...
true
0cf9714e74ce9d628a125ed7382827ea3729b3b0
Rust
d-z-h/rust-guide
/examples/concurrency/parallel/examples/rayon-parallel-search.rs
UTF-8
330
3.078125
3
[ "MIT", "Apache-2.0" ]
permissive
use rayon::prelude::*; fn main() { let v = vec![6, 2, 1, 9, 3, 8, 11]; let f1 = v.par_iter().find_any(|&&x| x == 9); let f2 = v.par_iter().find_any(|&&x| x % 2 == 0 && x > 6); let f3 = v.par_iter().find_any(|&&x| x > 8); assert_eq!(f1, Some(&9)); assert_eq!(f2, Some(&8)); assert!(f3 > Som...
true
7ab4e20b893ddd5ff331eb833f0c6f3e481fe46a
Rust
mrozbarry/rust-meta-weather
/src/main.rs
UTF-8
5,548
2.8125
3
[]
no_license
#[macro_use] extern crate serde_derive; extern crate reqwest; use reqwest::Error; #[derive(Deserialize, Debug)] struct Location { title: String, location_type: String, woeid: u32, latt_long: String, } type LocationCollection = Vec<Location>; #[derive(Deserialize, Debug)] struct ConsolidatedWeather { ...
true
52e41d3a64eefdbbef7e8a1ba1959f1ada8d7144
Rust
Kostassoid/lethe
/src/storage/windows/mod.rs
UTF-8
2,261
2.8125
3
[ "Apache-2.0" ]
permissive
#![cfg(windows)] extern crate winapi; use crate::storage::*; #[macro_use] mod helpers; mod meta; use super::windows::meta::*; mod access; use access::*; mod misc; use misc::*; use anyhow::{Context, Result}; impl System { pub fn enumerate_storage_devices() -> Result<Vec<StorageRef>> { let enumerator =...
true
bc2c95344b2bbcbc45f2741367a0abca9880c10b
Rust
Matthias-Fauconneau/iced
/wgpu/src/image/atlas/entry.rs
UTF-8
531
2.71875
3
[ "MIT" ]
permissive
use crate::image::atlas; #[derive(Debug)] pub enum Entry { Contiguous(atlas::Allocation), Fragmented { size: (u32, u32), fragments: Vec<Fragment>, }, } impl Entry { #[cfg(feature = "image")] pub fn size(&self) -> (u32, u32) { match self { Entry::Contiguous(alloc...
true
be69a21ed984a3d4db15a7b8c1b2c3abfae74755
Rust
leontoeides/google_maps
/src/places/business_status.rs
UTF-8
5,849
3.359375
3
[ "MIT", "Apache-2.0" ]
permissive
//! The `business_status` field within the _Places API_ _Place_ response //! object indicates the operational status of the place, if it is a business. use crate::error::Error as GoogleMapsError; use crate::places::error::Error as PlacesError; use phf::phf_map; use serde::{Deserialize, Deserializer, Serialize, Seriali...
true
606a5da40d932847b0c2f37f1a5d04bd57c27e34
Rust
aticu/nuefil
/src/loaded_image.rs
UTF-8
2,585
3.203125
3
[ "MIT" ]
permissive
//! Can be used on any image handle to obtain information about the loaded image. use crate::{memory::MemoryType, status::Status, system::SystemTable, Handle}; use core::fmt; /// Each loaded image has an image handle that supports EFI_LOADED_IMAGE_PROTOCOL. When an /// image is started, it is passed the image handle ...
true
5bb476b8e97d18be75edea7ec841c8b52e569469
Rust
asandst/aoc_2020
/src/bin/day6_2.rs
UTF-8
421
2.59375
3
[]
no_license
extern crate itertools; use std::collections::HashSet; use std::fs; use std::io; use itertools::Itertools; fn main() -> io::Result<()> { let input = fs::read_to_string("input_day6").unwrap(); println!("{:?}", input.split("\r\n\r\n").map(|g| g.split("\r\n").map(|p| p.chars().collect::<HashSet<char>>()).fold1(|x...
true
bc152d579a4f57900fb04fba5cbb71ae7928b3ed
Rust
grievejia/rpcomb
/src/combinator/token_parser.rs
UTF-8
1,341
3.1875
3
[ "MIT" ]
permissive
use internal::{ParseOutput, InputStream}; use parser::Parser; pub struct TokenParser<P> { parser: P } impl<'t, P> Parser<'t> for TokenParser<P> where P: Parser<'t> { type OutputType = P::OutputType; fn parse<T: InputStream<'t, T>>(&self, input: T) -> ParseOutput<T, Self::OutputType> { let mut i = 0; for ch in...
true
c1258c93aa98e4496a458a0494b8bf101114fb69
Rust
Noah2610/fsmus
/src/config.rs
UTF-8
2,708
3.21875
3
[ "MIT" ]
permissive
use std::fs::File; use std::net::IpAddr; use std::path::PathBuf; #[derive(Deserialize, Debug)] pub struct Config { /// The root directory from which to check for music and playlist directories. /// Can use "~", which expands to the user's home directory. pub music_dir: PathBuf, /// The host IP ...
true
c81697cc48cb43ac2d4db145a3a7838301e77b2a
Rust
ivanceras/balisong
/src/lod.rs
UTF-8
1,388
3.40625
3
[ "MIT" ]
permissive
//computes the limit and volumes of based on LOD //lod can not be greater than 9 use std::fmt; use constants; pub struct LOD{ pub lod:u8, pub limit:u32, pub volume:u64, } impl LOD{ pub fn new(lod:u8)->LOD{ if lod > constants::MAX_LOD{ panic!("LOD can not be greater than {}", cons...
true
d6ca89a3b0c8de7837da2f25fa512f898fb08cb5
Rust
GrossBetruger/RustPlaygound
/oop/src/lib.rs
UTF-8
1,029
3.6875
4
[]
no_license
pub struct AveragedCollection { list: Vec<f32>, average: f64, } impl AveragedCollection { pub fn new() -> AveragedCollection { AveragedCollection { list: vec![], average: 0., } } pub fn add(&mut self, item: f32) { self.list.push(item); self.u...
true
933f2f9b3301f044142ba7c76ed33ad62b97df09
Rust
topliceanu/learn
/rust/guessing-game-api/src/main.rs
UTF-8
1,686
3.3125
3
[ "MIT" ]
permissive
#[macro_use] extern crate rocket; #[get("/")] fn index() -> &'static str { "Hi" } #[launch] fn rocket() -> _ { rocket::build().mount("/", routes![index]) } /* use std::io::{Read, Write, BufReader, BufRead}; use std::net::{TcpListener, TcpStream}; fn main() { // bind allows us to create a connection on t...
true
457b95aa95bf629b22e362b09db09f25c9ce3913
Rust
ocadaruma/redis-nativemsgpack
/src/msgpack/format.rs
UTF-8
1,136
3.171875
3
[ "Apache-2.0" ]
permissive
use super::ByteVector; use std::mem::size_of; /// Represents msgpack primitive pub trait Primitive where Self: Sized + Ord, { const FIRST_BYTE: u8; const SIZE: usize; fn read<T: ByteVector>(bytes: &T, from: usize) -> Option<Self>; fn write<T: ByteVector>(bytes: &mut T, from: usize, value: Self); ...
true
fe8c307dc0509d0a8a2c256c52666e4157ad3ae1
Rust
Jaxii/dorker
/src/dork.rs
UTF-8
5,306
2.578125
3
[]
no_license
extern crate reqwest; extern crate select; use futures::executor::block_on; use reqwest::blocking::Client; use reqwest::header::USER_AGENT; use select::document::Document; use select::node::Node; use select::predicate::{Attr, Class, Element, Name, Predicate, Text}; use std::collections::HashMap; use std::error::Error;...
true
3afb4b2e2db866d69e321ca5994f8e792f036d41
Rust
kubo/rust-oracle
/src/conn.rs
UTF-8
1,780
2.5625
3
[ "UPL-1.0", "Apache-2.0" ]
permissive
// Rust-oracle - Rust binding for Oracle database // // URL: https://github.com/kubo/rust-oracle // //----------------------------------------------------------------------------- // Copyright (c) 2017-2021 Kubo Takehiro <kubo@jiubao.org>. All rights reserved. // This program is free software: you can modify it and/or ...
true
80fe0fb2335c536ec14455842f2b8febb1023d32
Rust
planet0104/art_pattern
/src/chapter2/sample5.rs
UTF-8
1,218
2.734375
3
[ "BSD-2-Clause" ]
permissive
use stdweb::web::CanvasRenderingContext2d; /*顶点 */ const VERTEXS: [(f64, f64); 3] = [(100.0, 100.0), (220.0, 100.0), (160.0, 50.0)]; pub fn draw(context: &CanvasRenderingContext2d) { /*画原三角形 */ draw_triangle(&VERTEXS, context, "#000"); let angle = 0.3; /*画旋转后的三角形 */ let rotate = |x: f64, y: f64,...
true
945cf62bf082a599c19d99119184505fb1c44925
Rust
TheAdnan/hrdja
/schrust/src/main.rs
UTF-8
1,652
3.546875
4
[ "Apache-2.0" ]
permissive
struct User { name: String, id: u32 } //printing function for User struct impl User { fn print_me(&self){ println!("User id: {:?} \nUsername: {:?}", &self.id, &self.name); } } //constructor equivalent impl User { fn new(name: String, id: u32) -> Self{ Self{ name: name, id: id } } } pub trait...
true
1424d035487d4acfb87c022f71d60cb0a023c66b
Rust
faraazahmad/loop
/src/row.rs
UTF-8
4,309
2.828125
3
[ "MIT" ]
permissive
use crate::highlighting; use std::cmp; use termion::color; use unicode_segmentation::UnicodeSegmentation; #[derive(Default)] pub struct Row { string: String, highlighting: Vec<highlighting::Type>, len: usize, } impl From<&str> for Row { fn from(slice: &str) -> Self { let mut row = Self { ...
true
19e7916ec853270cb372e77a6b8fc8c610082a05
Rust
oknowles/advent-of-code
/rust/aoc2022/src/days/day04.rs
UTF-8
1,638
3.328125
3
[]
no_license
fn read_input(input: &str) -> Vec<((u32,u32), (u32,u32))> { input.lines() .map(|l| { let pairs = l.split(',').collect::<Vec<&str>>(); let i1 = pairs[0].split('-').map(|c| c.parse::<u32>().unwrap()).collect::<Vec<u32>>(); let i2 = pairs[1].split('-').map(|c| c.parse::<u32>...
true
9068d1e23634a15415e26a05a7eb6262ae7ad301
Rust
hashedone/rust-tutorial
/1-hello/echo/src/main.rs
UTF-8
175
2.53125
3
[ "MIT" ]
permissive
use std::io::{stdin, BufReader, BufRead}; fn main() { let lines = BufReader::new(stdin()).lines(); for line in lines { println!("{}", line.unwrap()); } }
true
5f0829c00030a1678bbe673519f9c71b7cc46d72
Rust
IThawk/rust-project
/rust-master/src/test/ui/macros/macro-at-most-once-rep-2015-rpass.rs
UTF-8
999
3.453125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(unused_mut)] // Check that when `?` is followed by what looks like a Kleene operator (?, +, and *) // then that `?` is not interpreted as a separator. In other words, `$(pat)?+` matches `pat +` // or `+` but does not match `pat` or `pat ? pat`. // edition:2015 macro_rules! foo { // Check fo...
true
50a0f52b2244653c57476e9b49fbef72b08ae239
Rust
mrsun-97/SYXrepo
/rs_projects/HBTlib/src/lib.rs
UTF-8
568
2.71875
3
[]
no_license
#[no_mangle] use std::cmp::Ordering; pub extern fn concu(p_stam:Vec<f64>, p_chan:Vec<f64>, num: usize, step: f64) -> i32 { let len = p_stam.len(); if len <= num { return -1; } let count: i32 = 0; let mut arr: Vec<(f64,f64)> = Vec::with_capacity(num); for i in 0..num { arr.push(...
true
5587acc7eec8557ff79e806e0e55b0b9f6af4e4a
Rust
akiles/embassy
/embassy-stm32/src/subghz/fallback_mode.rs
UTF-8
938
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
/// Fallback mode after successful packet transmission or packet reception. /// /// Argument of [`set_tx_rx_fallback_mode`]. /// /// [`set_tx_rx_fallback_mode`]: crate::subghz::SubGhz::set_tx_rx_fallback_mode. #[derive(Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[repr(u8)]...
true
9a0890ce7ff9a3669568d80001e2d3ef2cc9e70e
Rust
mm304321141/rush
/src/xlib/rs64/double.rs
UTF-8
2,904
2.765625
3
[ "MIT" ]
permissive
class double { rd64 m_in ~double() { } double() { } double(double a) { mov64 rsi,this mov64 [rsi],a } double(double& a) { mov64 rdi,this mov64 rsi,a mov64 [rdi],[rsi] } //这个整数转浮点很慢 double(int a) { rstr s(a) xf.sscanf(s.cstr,"%lf",&this) } double(ui...
true
56287ed1b3d10f89aa48654f1dbac33451dee0f9
Rust
rgambee/advent-of-code
/2021/src/day02/solution02.rs
UTF-8
1,746
3.140625
3
[]
no_license
use crate::util; use std::fs; use std::iter::FromIterator; use std::path; pub fn solve(input_path: path::PathBuf) -> util::Solution { let contents = fs::read_to_string(&input_path) .unwrap_or_else(|_| panic!("Failed to read input file {:?}", input_path)); let line_iter = contents.lines(); let mut h...
true
82855c8dc7368bc6b7a4dbf268c1f4532fd9e680
Rust
jkordish/shouji
/src/main.rs
UTF-8
3,170
2.765625
3
[ "MIT" ]
permissive
#![cfg_attr(feature="clippy", plugin(clippy))] #![feature(custom_derive, plugin, custom_attribute, type_macros)] #![plugin(serde_macros, docopt_macros)] extern crate serde; extern crate serde_json; extern crate rustc_serialize; extern crate docopt; mod actions; use self::actions::*; docopt!(Args derive, " shouji -- i...
true
ca8cde43cd959ce6b1e91247156b1c6919c07750
Rust
DorianListens/advent2017
/src/day_one/mod.rs
UTF-8
639
2.859375
3
[]
no_license
#[cfg(test)] mod tests; pub mod input; pub fn rotated_inverse_captcha(input: &str) -> u32 { let advanced_by_half = input .chars() .cycle() .skip(input.len() / 2) .take(input.len()); input .chars() .zip(advanced_by_half) .filter(|x| x.0 == x.1) .f...
true
74c88c9177e86bc7b72fb4fc47dd4dedbb51f5b5
Rust
sailingchannels/crawler
/src/repos/additional_channel_repo.rs
UTF-8
1,225
2.84375
3
[]
no_license
use anyhow::Error; use futures::stream::TryStreamExt; use mongodb::bson::{doc, Document}; use mongodb::{Client, Collection}; use crate::utils::db::get_db_name; pub struct AdditionalChannelRepository { collection: Collection<Document>, } impl AdditionalChannelRepository { pub fn new(client: &Client, environme...
true
fd2a097449c6909ebb21ee4fd7829dc37ca4fd14
Rust
katyo/literium
/rust/backend/src/auth/method/native.rs
UTF-8
2,188
2.796875
3
[ "MIT" ]
permissive
/*! ### Native auth This method provides classic authorization with *username* and *password*. */ use auth::{AuthError, IsAuthMethod}; use base::BoxFuture; use futures::Future; use user::{verify_password, HasPasswordHash, HasUserStorage, IsUserStorage}; /// Native auth method information #[derive(Debug, Serialize)...
true
a6119b6ef76f4fdace169b9f327038fcca2321a4
Rust
zhangf911/swiboe
/src/ipc.rs
UTF-8
3,038
2.71875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Swiboe development team. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE.txt // in the project root for license information. use ::Result; use ::rpc; use mio::{TryRead, TryWrite}; use serde_json; use std::error::Error; use std::io::{Read, Write}; #[derive(Seria...
true
18fb9cbdfea40d41d5ffd86e64e3ffb5cfe093f4
Rust
KristonCosta/five-am
/src/server/map_builders/shop_builder.rs
UTF-8
1,037
2.75
3
[]
no_license
use crate::geom::Rect; use crate::map::{Map, TileType}; use crate::server::map_builders::{BaseMapBuilder, BuiltMap}; use rand::prelude::ThreadRng; pub struct ShopBuilder; impl BaseMapBuilder for ShopBuilder { fn build(&mut self, _: &mut ThreadRng, build_data: &mut BuiltMap) { let size: (i32, i32) = build_...
true
bb66804b36426234d178b6feef197520639d8e7d
Rust
Ogeon/palette
/palette/src/yxy.rs
UTF-8
15,961
2.59375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types for the CIE 1931 Yxy (xyY) color space. use core::{ marker::PhantomData, ops::{Add, AddAssign, BitAnd, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, }; #[cfg(feature = "approx")] use approx::{AbsDiffEq, RelativeEq, UlpsEq}; #[cfg(feature = "random")] use rand::{ distributions::{ unifo...
true
c23ca69b25f13d03e5b8e5bde1c41ce70c71f29d
Rust
jeffrey-xiao/neso-gui
/src/config.rs
UTF-8
16,071
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use log::warn; use sdl2::controller::Button; use sdl2::keyboard::Keycode; use serde::de::{Deserialize, Deserializer, Error, SeqAccess, Unexpected, Visitor}; use serde_derive::Deserialize; use std::collections::HashMap; use std::fmt; use std::fs; use std::marker::PhantomData; use std::path::{Path, PathBuf}; use std::str...
true
a2e55a1d0b90785f84576ff23e980d2c85157e17
Rust
CheaterCodes/AoC2020
/day13/src/main.rs
UTF-8
3,176
3.5625
4
[ "MIT" ]
permissive
use std::{env, error::Error}; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; // Convenience macro for generating errors macro_rules! error { ($($arg:tt)*) => {{ let res = format!($($arg)*); Box::<dyn Error>::from(res) }}; } // Build and run with `cargo run -- ./input.txt` ...
true
7dbc1d99475c52b60a205c11cac331f95b783d1a
Rust
dakom/awsm-renderer
/crate/src/image.rs
UTF-8
4,850
2.53125
3
[ "MIT", "Apache-2.0", "BSD-2-Clause" ]
permissive
use std::io::Cursor; use crate::prelude::*; use awsm_web::{loaders::{fetch::fetch_url, image::load as fetch_image}, data::{ArrayBufferExt, TypedData}, webgl::{TextureTarget, TextureOptions, PixelInternalFormat, DataType, PixelDataFormat, TextureWrapTarget, TextureWrapMode, TextureMinFilter, TextureMagFilter, WebGlTextu...
true
b20efd53e85d9b19696e7ebfff1d2ee8b061673a
Rust
polarislee1984/wifi-connect
/src/orientation.rs
UTF-8
1,030
3.15625
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::Read; use std::fs; pub fn SetOrientation(orientation:String) { let mut file = File::open("/boot/config.txt").expect("unable to read"); let mut contents = String::new(); file.read_to_string(&mut contents); if contents.find("display_rotate=") == None { // add displ...
true
e33db74d61260d7bbdbd944639aac51937877c04
Rust
pizzamig/structopt-flags
/examples/hostip.rs
UTF-8
513
2.65625
3
[ "BSD-3-Clause" ]
permissive
use std::net::{IpAddr, Ipv6Addr}; use structopt::StructOpt; use structopt_flags::GetWithDefault; #[derive(Debug, StructOpt)] #[structopt(name = "hostip", about = "An example using HostOpt option")] struct Opt { #[structopt(flatten)] hostip: structopt_flags::HostOpt, } fn main() -> Result<(), Box<dyn std::erro...
true
29186b5aef81b325bff660067c086eff7c8e4a43
Rust
ernestyalumni/HrdwCCppCUDA
/Constructicon/Mixmaster/projects/package_collections_etc/src/oop/gui.rs
UTF-8
4,926
3.6875
4
[ "MIT" ]
permissive
//------------------------------------------------------------------------------------------------- /// \url https://doc.rust-lang.org/book/ch17-02-trait-objects.html#defining-a-trait-for-common-behavior /// \details A trait object points to both an instance of a type implementing our specified trait /// and a table us...
true
e48c632fd98c2c323e4d16d5a0bbad2c17950ee3
Rust
matklad/quadheap
/src/quad_heap.rs
UTF-8
2,460
3.453125
3
[]
no_license
pub struct QuadHeap<T> { pub(crate) vec: Vec<T>, } impl<T: Ord + std::fmt::Debug> QuadHeap<T> { pub fn with_capacity(cap: usize) -> QuadHeap<T> { QuadHeap { vec: Vec::with_capacity(cap), } } pub fn push(&mut self, value: T) { self.vec.push(value); self.sift_...
true
15d2615e497a82afaa473d9e128d83d6638b313a
Rust
doytsujin/yew
/examples/function_todomvc/src/components/filter.rs
UTF-8
768
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
use yew::prelude::*; use crate::state::Filter as FilterEnum; #[derive(PartialEq, Properties)] pub struct FilterProps { pub filter: FilterEnum, pub selected: bool, pub onset_filter: Callback<FilterEnum>, } #[function_component] pub fn Filter(props: &FilterProps) -> Html { let filter = props.filter; ...
true
348f6ae13a4bd1deac512da647059922c570f4fb
Rust
heymind/note-app-one-hour-a-day
/crates/sqlxorm/src/generator/column_def.rs
UTF-8
2,092
2.6875
3
[]
no_license
use super::FieldDataType; use anyhow::Result; use sqlx::{FromRow, PgConnection}; #[derive(Debug, FromRow)] pub struct ColumnDef { pub table_name: String, pub column_name: String, pub is_nullable: String, pub udt_name: String, pub constraint_type: Option<String>, } impl ColumnDef { pub async fn ...
true
2d89cfb7d8dd4bc91c871fb7a953331d1cc56f35
Rust
youngqqcn/RustNotes
/examples/ch16/rust_channel_1.rs
UTF-8
2,341
3.734375
4
[]
no_license
use std::thread; use std::sync::mpsc::{ channel }; use std::time::Duration; fn foo1(){ let (tx, rx) = channel(); thread::spawn(move||{ let msg = String::from("goood"); tx.send(msg).expect("send error"); }); let recv_msg = rx.recv().expect("receive error"); println!("receive ...
true
3423a58f205b16e497f3e1792a4136b9c4d44f89
Rust
asg0451/nbor
/src/planet.rs
UTF-8
1,350
3.125
3
[]
no_license
use crate::vec2::*; use std::cmp::PartialEq; static mut NEXT_ID: i32 = 0; // TODO should this be copy? #[derive(Clone, Copy, Debug)] pub struct Planet { id: i32, mass: f64, loc: Vec2<f64>, vel: Vec2<f64>, } impl Planet { pub fn id(&self) -> i32 { self.id } pub fn mass(&self) -> f6...
true
4d12937225c723482c753f6b8ddceb7374b04647
Rust
Walker-os/delay-timer
/examples/demo.rs
UTF-8
5,279
2.671875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::Result; use delay_timer::prelude::*; use smol::Timer; use std::thread::{current, park, sleep, Thread}; use std::time::Duration; use surf; // cargo run --package delay_timer --example demo --features=full fn main() { let delay_timer = DelayTimerBuilder::default().enable_status_report().build(); let...
true
7fdf43daa42db9df27e11313fc1332631c30ed9a
Rust
paulkirkwood/rs.parcoursdb
/tests/test_tour_de_france.rs
UTF-8
192,206
2.78125
3
[]
no_license
extern crate parcoursdb; extern crate chrono; #[cfg(test)] mod test { use parcoursdb::tour_de_france::repository::*; #[test] fn test_tour_de_france_1903() { let route = [ "1,1 July,Paris to Lyon,467.0 km,Road stage", "2,5 July,Lyon to Marseille,374.0 km,Road stage", ...
true
5a07fd45765dd1862cc558746d3a25120a820a2d
Rust
willdoescode/hera
/src/parser/mod.rs
UTF-8
12,021
3.3125
3
[ "MIT" ]
permissive
#[cfg(test)] pub mod test; use crate::{ast::*, lexer::Lexer, token::Token}; pub struct Parser { pub l: Lexer, pub current_token: Token, pub peek_token: Token, pub errors: Vec<String>, } impl Parser { pub fn new(lexer: Lexer) -> Self { let mut p: Parser = Parser { l: lexer, ...
true
d76754865d7abff5fd3b44b0f7a7d30ff52e6d45
Rust
zellij-org/zellij
/zellij-client/src/old_config_converter/old_config.rs
UTF-8
42,838
2.640625
3
[ "MIT" ]
permissive
// This is a converter from the old yaml config to the new KDL config. // // It is supposed to be mostly self containing - please refrain from adding to it, importing // from it or changing it use std::fmt; use std::path::PathBuf; use serde::de::{Error, Visitor}; use serde::{Deserialize, Deserializer, Serialize}; use ...
true
68fe71e77dae48c120540483951d543c62a1ee28
Rust
tomaka/acpi
/acpi/src/rsdp_search.rs
UTF-8
4,387
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{parse_validated_rsdp, rsdp::Rsdp, Acpi, AcpiError, AcpiHandler}; use core::{mem, ops::RangeInclusive}; use log::warn; /// The pointer to the EBDA (Extended Bios Data Area) start segment pointer const EBDA_START_SEGMENT_PTR: usize = 0x40e; /// The earliest (lowest) memory address an EBDA (Extended Bios Data...
true
950fd17b4fb01e7d8dfdcc5cc4543523ecc5fc5b
Rust
isabella232/BellmanBindings-iOS
/cargo/src/filesystem/mod.rs
UTF-8
849
2.703125
3
[]
no_license
use std::fs::File; use std::io::{BufReader, Read}; use std::error::Error; use std::env; use std::io::prelude::*; use std::ffi::{CString, CStr}; use bellman::groth16::VerifyingKey; use bellman::pairing::Engine; pub extern fn get_verifying_key_from_file<E: Engine>(filename: String) -> Result<VerifyingKey<E>, Box<Error>...
true
1dbc8c0371301b3667d809941430873ac7dcb80d
Rust
nervosnetwork/ckb
/util/occupied-capacity/core/src/units.rs
UTF-8
4,389
3.640625
4
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; /// CKB capacity. /// /// It is encoded as the amount of `Shannons` internally. #[derive( Debug, Clone, Copy, Default, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, )] pub struct Capacity(u64); /// Represents the ratio `numerator / denominator`, where `numerato...
true
7e3b470f29f8ba2370610a99c9140bd5ee95860b
Rust
bing050802/leetcode-rust-repo
/1566/main.rs
UTF-8
530
2.765625
3
[]
no_license
impl Solution { pub fn contains_pattern(arr: Vec<i32>, m: i32, k: i32) -> bool { let n = arr.len(); if n < (m * k) as usize { return false; } let end = n - (m * k) as usize; let m = m as usize; for i in 0..=end { let mut res = true; for j in 1..k as usize { ...
true
16f887cc346fde67625a409d0edc25ebc6039ce1
Rust
rossmacarthur/sheldon
/src/lock/source/local.rs
UTF-8
2,014
3
3
[ "Apache-2.0", "MIT" ]
permissive
use std::path::PathBuf; use anyhow::{anyhow, Result}; use crate::context::Context; use crate::lock::source::LockedSource; /// Checks that a Local source directory exists. pub fn lock(ctx: &Context, dir: PathBuf) -> Result<LockedSource> { let dir = ctx.expand_tilde(dir); if dir.exists() && dir.is_dir() { ...
true
967892252e4dd2d45643b5e5d710b1f2d8bb27a5
Rust
tadic-luka/raymarching_sdf
/src/shader/mod.rs
UTF-8
6,398
2.59375
3
[]
no_license
use gl::types::*; use std::ptr; use std::ffi::CString; const GLSL_VERSION: &'static [u8] = b"#version 310 es\nprecision highp float;\n\0"; const VERTEX_SHADER_SOURCE: &'static str = include_str!("../../assets/shaders/main.vert"); const FRAGMENT_SHADER_SOURCE: &'static str = include_str!("../../assets/shaders/main.fra...
true
078b00206d879834c279f0aa9f42f1d678027d23
Rust
rodya-mirov/aoc_2017
/src/day04.rs
UTF-8
1,361
3.40625
3
[]
no_license
use std::collections::HashSet; const INPUT: &str = include_str!("input/4.txt"); fn is_valid_4a(line: &str) -> bool { let mut seen: HashSet<String> = HashSet::new(); for token in line.split_whitespace() { if !seen.insert(token.to_string()) { return false; } } true } fn is...
true
8f41612d7e52921d926f3979719f95b2a3c6578d
Rust
time-rs/time
/time/src/parsing/combinator/rfc/iso8601.rs
UTF-8
5,659
3.4375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Rules defined in [ISO 8601]. //! //! [ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html use core::num::{NonZeroU16, NonZeroU8}; use crate::parsing::combinator::{any_digit, ascii_char, exactly_n_digits, first_match, sign}; use crate::parsing::ParsedItem; use crate::{Month, Weekday}; /// What kind ...
true
74c067e14eab52dfdb517629c465cae85a1a35e6
Rust
ekarademir/rust-learning
/sdl2-base-project/src/rotatingwave/color.rs
UTF-8
10,880
2.703125
3
[]
no_license
//! # `color` //! Color related stuff, named colors and themes #[allow(unused_imports)] use sdl2::pixels::Color; pub struct NamedColours; impl NamedColours { pub const WHITE: Color = Color {r: 255, g: 255, b: 255, a: 0xff}; pub const BLACK: Color = Color {r: 0, g: 0, b: 0, a: 0xff}; pub const RED: Color = ...
true
52c4e284ecfa56201b7e25d111686a2344ac9748
Rust
bazaah/jaesve
/src/models/error.rs
UTF-8
8,573
3.03125
3
[ "MIT" ]
permissive
use std::{ error, fmt::Debug, io::Error as ioError, process::exit as terminate, str::Utf8Error, sync::mpsc::SendError, }; #[cfg(feature = "config-file")] use toml::de::Error as TomlError; pub(crate) type Result<T> = std::result::Result<T, Error>; #[derive(Debug)] pub struct Error { kind: ErrorKind, c...
true
ca16f9236310232a751288b52bc8f0e8f695d0f2
Rust
Hbowers/sneat
/src/sneat.rs
UTF-8
3,691
2.59375
3
[]
no_license
use amethyst::{ core::transform::Transform, input::{is_key_down, VirtualKeyCode}, prelude::*, }; use serde::{Deserialize, Serialize}; use std::env; use std::fs; use std::path::PathBuf; use crate::components::{Animation, Barrel, Coverable, Covers, Floor, Shape, Sneatling, Velocity}; use crate::constants::{A...
true
26dc87890b82e7c24642f92afdc30d57803d7bd3
Rust
Mountlex/kserver
/serverlib/src/request.rs
UTF-8
2,548
3.796875
4
[]
no_license
/// Represents a request for a server problem on the line. /// /// A request consists of two parts: `s` and `t`. If `s==t`, the requests is called simple, other wise relocating. /// For the k-server problem on the line, only simple requests are allowed. The k-taxi problem allows both types of requests. /// If a server ...
true
0e18ce803fcbbec19d4ec6258e472e3ace93d087
Rust
happyborg/gitoxide
/git-packetline/src/provider/read.rs
UTF-8
5,259
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ borrowed::{Band, Text}, PacketLine, Provider, MAX_DATA_LEN, }; use std::io; /// Note: Reading from this intermediary copies bytes 3 times: /// OS -> (parent) line provider buffer -> our buffer -> caller's output buffer pub struct ReadWithSidebands<'a, T, F> where T: io::Read, { parent: &'a...
true
17b8a96a810a612acf9b4da9f725b1bafa031ca2
Rust
jsim2010/paper
/src/io/ui/error.rs
UTF-8
2,036
3.078125
3
[ "MIT" ]
permissive
//! Implements errors thrown by the user interface. #![allow(clippy::module_name_repetitions)] // It is appropriate for items to end with `Error`. use {crossterm::ErrorKind, thiserror::Error as ThisError}; /// An error creating a [`Terminal`]. #[derive(Debug, ThisError)] #[error(transparent)] pub enum CreateTerminalEr...
true
14c805397ea793cab15ec01b079aa5fd68dcce4d
Rust
vinc/level
/src/device.rs
UTF-8
164
2.53125
3
[ "MIT" ]
permissive
use std::thread::JoinHandle; pub trait Device { fn name(&self) -> String; fn level(&self) -> u64; fn set_level(&self, level: u64) -> JoinHandle<()>; }
true
ea43733c329dff20d4afaf2839601d6e9e249b64
Rust
travisjeffery/showrss-to-magnet
/src/main.rs
UTF-8
2,498
2.890625
3
[]
no_license
use clap::{App, Arg}; use log::info; use quick_xml::de::from_str; use serde::Deserialize; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::{str, thread, time}; #[derive(Debug, Deserialize, PartialEq)] struct Item { title: String, link: String, guid: String, } #[derive(Debug, Deser...
true
6fa7d27ce96e86bf5ee63770a4e26d6a0d848d4e
Rust
lpenet/advent_of_code_2019
/2/2a.rs
UTF-8
1,084
3.09375
3
[]
no_license
use std::fs; fn main() { let input_filename = "input.txt"; let content = fs::read_to_string(input_filename) .expect(&format!("Something went wrong reading {}", input_filename)); let mut input_vector: Vec<u64> = content.split(",").map(str::parse::<u64>).filter_map(Result::ok).collect(); input_ve...
true
1111d7dc4379d0eb9e3edcca84c0a18f8989383c
Rust
tearne/library
/rust/20_command/src/bin/test.rs
UTF-8
333
2.90625
3
[]
no_license
#![allow(unused)] fn main() { use std::process::{Command, Stdio}; use std::io::{self, Write}; let output = Command::new("rev") .stdin(Stdio::inherit()) .stdout(Stdio::piped()) .output() .expect("Failed to execute command"); print!("You piped in the reverse of: "); io::stdout().write_all(&output.stdout...
true
bbf665037e92751046724dd6f138a85b0f74e4d3
Rust
CommunityDragon/cdragon-rs
/cdragon-hashes/src/lib.rs
UTF-8
10,081
3.53125
4
[]
no_license
//! Tools to work with hashes, as used by cdragon //! //! Actual hash values are created with [crate::define_hash_type!()], which implements [HashDef] and //! conversions. //! //! [HashMapper] manages a mapping to retrieve a string from a hash value. //! The type provides methods to load mapping files, check for known ...
true
317f7d9ab9803e1f80ba6ecc675a955d54244add
Rust
finnbear/rustrict
/src/buffer_proxy_iterator.rs
UTF-8
2,097
3.609375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::VecDeque; use std::iter::Iterator; use std::ops::RangeInclusive; /// This iterator buffers characters until they can be determined to be clean of profanity. pub(crate) struct BufferProxyIterator<I: Iterator<Item = char>> { iter: I, /// The index into iter of the start of buffer. buffe...
true
e86750456cfcea11c15fdaab937a0bfc63502cca
Rust
andrew4fr/dwemthys
/src/movement/mod.rs
UTF-8
2,958
3.109375
3
[]
no_license
use crate::game::Game; use crate::util::Contains::{DoesContain, DoesNotContain}; use crate::util::{Bound, Point, XPointRelation, YPointRelation, PointEquality}; use rand::prelude::*; use tcod::input::KeyCode::{Down, Left, Right, Up}; pub trait MovementComponent { fn update(&self, p: Point) -> Point; } pub struct ...
true
13d4ba8fac19f0cfd6403dfc2af9ed92f1f021b7
Rust
Tzian/octothorp
/src/octree.rs
UTF-8
7,205
3.6875
4
[]
no_license
use error::OctreeError; use node::{NodeLoc, OctreeNode}; use serde::{Serialize, Deserialize}; use std::{fmt, u8}; /// Octree structure #[derive(Serialize, Deserialize)] pub struct Octree<T> { dimension: u16, max_depth: u8, root: OctreeNode<T>, } impl<T> Octree<T> where T: Copy + PartialEq, { /// C...
true
0e0aa676023a4af85b67a30e64484130ab3c1038
Rust
ComplicatedPhenomenon/flashlight
/preparation/format.rs
UTF-8
549
3.125
3
[]
no_license
use std::fmt; use std::collections::HashSet; fn main(){ let s = fmt::format(format_args!("hello {}", "world")); println!("{}", s); let name = "szaghi"; let s1 = fmt::format(format_args!("https://github.com/{}?tab=following", name)); println!("{}", s1); let mut names = HashSet::new(); name...
true
10e920e199698798dbaafed9cf2bde1bbc85bf98
Rust
etherbanking/wasm-utils
/build/src/main.rs
UTF-8
3,558
2.546875
3
[]
no_license
//! Experimental build tool for cargo extern crate glob; extern crate wasm_utils; extern crate clap; extern crate parity_wasm; use std::{fs, io}; use std::path::PathBuf; use clap::{App, Arg}; #[derive(Debug)] pub enum Error { Io(io::Error), NoSuitableFile(String), TooManyFiles(String), NoEnvVar, } impl From<io...
true
16d89ffdc93520d25f97615ea35771ab3357d228
Rust
matthiasSchedel/RustAirHockey
/src/airhockey/player.rs
UTF-8
4,918
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! Airhockey Player. use super::helper; /// player radius pub const RADIUS: u16 = 30; /// player fill color pub const COLOR: u32 = 0xfff000; /// player radius pub const STROKE_COLOR: u32 = 0xfff000; /// has the player stroke? pub const HAS_STROKE: bool = false; use super::field; use super::graphics_handler::GraphicsH...
true
320357ee93b685d54951c14ff3272081c642b91a
Rust
andrewdupont/rust-tutorial
/fizzbuzz2.rs
UTF-8
341
3.3125
3
[]
no_license
fn fizz_buzz(count: i32) -> String { if count % 15 == 0 { "FizzBuzz".to_string() } else if count % 3 == 0 { "Buzz".to_string() } else if count % 5 == 0 { "Fizz".to_string() } else { count.to_string() } } fn main() { for i in 1..101 { println!("{}", fi...
true
15809caefa03cbfa2a522072d9735779fb7c63f7
Rust
rust-in-action/code
/ch5/ch5-int-vs-int.rs
UTF-8
152
2.53125
3
[]
no_license
fn main() { let a: u16 = 50115; let b: i16 = -15421; println!("a: {:016b} {}", a, a); // <1> println!("b: {:016b} {}", b, b); // <1> }
true
452b285b84ed58b25a8f024c570a9286f9e3a157
Rust
dialtone/aoc
/src/solutions/year2022/day11.rs
UTF-8
6,607
2.796875
3
[ "MIT" ]
permissive
// use crate::solutions::clear_screen; // use crate::solutions::go_to_top; pub struct Monkey { pub stack: Vec<u64>, pub op: Op, pub div: u64, pub conditions: (usize, usize), } #[derive(Clone, Copy)] pub enum Op { Square, Add(u64), Mul(u64), } pub fn parse(input: &[u8]) -> Vec<Monkey> { ...
true
02066d07d96a9241a3e17c415ecdbdd2d92b09de
Rust
ExcaliburZero/chip8_interpreter
/src/bit_operations.rs
UTF-8
3,500
3.84375
4
[ "MIT" ]
permissive
//! Bit-based operations for u8 and u16 values. pub type InstructionNibbles = (u8, u8, u8, u8); /// Returns the nth bit of the given byte as a bool. /// /// Indexed with 0 being the last bit of the byte. /// /// ```rust /// # use chip8_interpreter::bit_operations::get_nth_bit; /// assert_eq!(Ok(true), get_nth_bit(1, ...
true