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
c0c31044089e7980d6bea2757bab6141e415fe10
Rust
wjzz/chess-in-rust
/src/bin/endgame.rs
UTF-8
10,162
2.78125
3
[]
no_license
use std::collections::HashMap; use rust_chess::position::*; pub type RESULT = i32; const WIN_W: RESULT = 1; const DRAW: RESULT = 0; const WIN_B: RESULT = -1; pub type TABLE = HashMap<u64, (RESULT, u64, IntMove)>; pub fn generate_index_pairs() -> Vec<(usize, usize)> { let mut v = vec![]; for &k1 in INDEXES88...
true
18c510ec6c426601fd7110ddc796296c8f85bbb7
Rust
tbourvon/ipdl-rs
/src/passes/type_check.rs
UTF-8
39,599
2.53125
3
[]
no_license
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::collections::{HashMap, HashSet}; use ast::*; use errors::Errors; const BUILTIN_TYPES: &[&str] = &[ ...
true
94ce20e99ae45ee5e5568ab1327be08e46d1b624
Rust
DukeKamono/lone_survivor
/src/player.rs
UTF-8
3,513
2.953125
3
[ "MIT" ]
permissive
use crate::enemy::Enemy; use ggez::graphics::Mesh; use ggez::*; pub struct Player { pub hp: u32, pub x: f32, pub y: f32, point: nalgebra::Point2<f32>, pub bullets: Vec<Bullet>, pub hitbox: graphics::Rect, } impl Player { pub fn new(xpos: f32, ypos: f32) -> Player { Player { ...
true
f176e56139fa5fd0ce6502f56160a2953b406b88
Rust
DoYouEvenCpp/aoc2015
/day02/src/main.rs
UTF-8
1,320
3.3125
3
[]
no_license
use std::fs; fn get_dimensions(line: &str) -> Vec<u32> { let mut dims: Vec<u32> = line .split('x') .map(|dimensions| dimensions.parse().unwrap()) .collect(); dims.sort(); dims } fn part_1(input: &str) -> u32 { input .lines() .map(|l| { let dim = get_...
true
fa2ab0f2dbc8fcd779b46060d2294480f410ec11
Rust
pierrechevalier83/advent_of_code_2019
/09/src/main.rs
UTF-8
2,016
3.0625
3
[]
no_license
#![deny(warnings)] use intcode_computer::Computer; use std::str::FromStr; fn main() { let computer = Computer::from_str(include_str!("input.txt")).unwrap(); { // 1: test mode let mut computer = computer.clone(); computer.set_mock_io_input("1"); computer.compute().unwrap(); ...
true
a67f7fb360509ce8b13c0b2e0b8053cf9e7d17d4
Rust
ahgibbons/rsha256
/src/main.rs
UTF-8
2,784
2.65625
3
[]
no_license
use std::io::Read; use std::fs::File; use std::num::Wrapping; use std::env; mod shafuncs; use shafuncs::CHUNKBYTES; macro_rules! wraparray { ( $( $x:expr),* ) => { [$(Wrapping($x)),*] } } fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let mut f = File::open(filename).expec...
true
6c80276605df9aac85ced817d9be56f8fc7c5108
Rust
marcmo/parsing_invalid_utf8
/src/main.rs
UTF-8
1,291
3.140625
3
[]
no_license
use std::fs; use std::io::BufRead; use std::io::BufReader; use std::io::Read; trait LossyLine { fn lossy_read_line(&mut self, buf: &mut String) -> std::io::Result<usize>; } impl<T: std::io::Read> LossyLine for BufReader<T> { fn lossy_read_line(&mut self, buf: &mut String) -> std::io::Result<usize> { l...
true
2ab0d7d19f56c9f613a87432ce9bf5ac47d96099
Rust
MingweiSamuel/spinach
/lib/src/comp/comptrait.rs
UTF-8
1,253
2.78125
3
[ "Apache-2.0" ]
permissive
use std::future::Future; use std::task::{Context, Poll}; use std::pin::Pin; use crate::op::Op; pub struct CompRunFuture<'s, C: Comp + ?Sized> { comp: &'s C, future: Pin<Box<C::TickFuture<'s>>>, } impl<'s, C: Comp + ?Sized> Future for CompRunFuture<'s, C> { type Output = Result<!, C::Error>; fn poll(...
true
8f586ff57ff17f5bc01b0b8b17e51625c8fcfb13
Rust
rkuhn/party-types
/src/protocol.rs
UTF-8
5,727
2.953125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ channel::{AsyncTransport, Either, Transport}, Channel, }; use anyhow::{bail, Result}; use std::{fmt::Debug, marker::PhantomData}; /// Receive a value T from the given Role pub struct Tx<Role, T, Cont> { pub(crate) cont: Cont, _ph: PhantomData<(Role, T)>, } impl<Role, T: Send + 'static, Con...
true
6868311deb06d850d0ac334b9f113d9f6e21156f
Rust
optozorax/olymp
/contests/codeforces/1459/src/c.rs
UTF-8
1,867
2.5625
3
[]
no_license
#[fastio::fastio] pub fn main() { let _n = read!(i64); let _m = read!(i64); let mut a = readln!(i64); let mut b = readln!(i64); a.sort_unstable(); let max_gcd = a.windows(2).map(|w| w[1] - w[0]).fold(0, gcd); b.iter_mut().for_each(|x| *x = gcd(*x + a[0], max_gcd)); println!("{}", SpaceVec(b)); } //------------...
true
d3a6143772586914fd5003b3a098ecfd8f931019
Rust
masonium/aoc2017
/src/day20.rs
UTF-8
3,322
3.109375
3
[]
no_license
use prelude::*; use std::ops::Sub; #[derive(Clone, Copy, Hash, PartialEq, Eq)] struct V { x: isize, y: isize, z: isize } impl V { fn new(x: isize, y: isize, z: isize) -> V { V { x: x, y: y, z: z } } } impl Sub<V> for V { type Output = V; fn sub(self, v: V) -> V { V {x: se...
true
a3dbd4bbc08426bee71680a61045f8cdd5e9fe25
Rust
mindthump/say_my_name
/src/main.rs
UTF-8
153
3.40625
3
[]
no_license
fn main() { let name = "Mary"; say_name(&name); say_name(&name); } fn say_name(name: &str) { println!("Hello, {}", name.to_string()); }
true
5cd7e5b29df49dc476e6566e0edad32bfc6eef6a
Rust
nabrozidhs/rust-adventofcode2017
/day10/main.rs
UTF-8
2,066
3.171875
3
[ "MIT" ]
permissive
use std::io; use std::io::Read; use std::str; fn part1(size: usize, input: &Vec<u32>, rounds: u32) -> Vec<u32> { let mut array: Vec<u32> = Vec::with_capacity(size); for i in 0..size { array.insert(i, i as u32); } let mut current_position = 0; let mut skip_size = 0; for _ in 0..rounds {...
true
5de3d908c2349e974a34d1364f4f8ce6ed574538
Rust
rust-lang/miri
/tests/pass/issues/issue-miri-133.rs
UTF-8
459
3.25
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::mem::size_of; struct S<U, V> { _u: U, size_of_u: usize, _v: V, size_of_v: usize, } impl<U, V> S<U, V> { fn new(u: U, v: V) -> Self { S { _u: u, size_of_u: size_of::<U>(), _v: v, size_of_v: size_of::<V>() } } } impl<V, U> Drop for S<U, V> { fn drop(&mut self) { ass...
true
d02a85dff6fcf2384e46c279f34101c46b3c2665
Rust
prajithkb/performance_test
/benches/benchmark.rs
UTF-8
2,145
2.96875
3
[]
no_license
use std::fmt::Display; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use performance_test::data_access; use performance_test::Data; #[macro_export] macro_rules! bench_data { ($ // Power of two in bytes id:expr, // Number items to iterate $num_items:expr,...
true
972da6f2f6c196052f3123c244c6e7df1c41cbba
Rust
boa-dev/boa
/boa_ast/src/statement/labelled.rs
UTF-8
4,491
3.3125
3
[ "MIT", "Unlicense" ]
permissive
use crate::{ function::Function, try_break, visitor::{VisitWith, Visitor, VisitorMut}, Statement, }; use boa_interner::{Interner, Sym, ToIndentedString, ToInternedString}; use core::ops::ControlFlow; /// The set of Parse Nodes that can be preceded by a label, as defined by the [spec]. /// /// Semantica...
true
964be98784d273472ace8ecab8876a267cd03c67
Rust
imp/interact
/interact/src/tokens/mod.rs
UTF-8
7,119
3.453125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/// Token parser for Interact input. /// /// Behind the scenes, we would like to perform parsing of certain types of expressions, mainly for /// the purpose of data access. The most common type of data access is dereferences of a struct /// field, i.e., `.field`. Others, include map indexing `["value"]`, so we only nee...
true
38ba560a8edc580bbb61deda977a65ab9971fbcc
Rust
fredlb/rusty-rays
/src/main.rs
UTF-8
9,606
2.75
3
[]
no_license
extern crate image; extern crate rand; extern crate time; use std::f32; mod math; use math::cross; use math::dot; use math::point_at_ray; use math::random_in_unit_disk; use math::random_in_unit_sphere; use math::Ray; use math::Vector3; use std::sync::{Arc, Mutex}; use std::thread; use time::PreciseTime; const KMIN_T:...
true
70acfab4606f34b4f42a5b204a4a8c2f6ae2b8e4
Rust
LucioFranco/amethyst-protocol
/src/net/socket_state.rs
UTF-8
6,017
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use bincode::serialize; use std::collections::HashMap; use std::sync::{Arc, RwLock}; use std::thread; use std::time::Duration; use super::{Connection, Packet, RawPacket, SocketAddr}; use error::{NetworkError, Result}; // Type aliases // Number of seconds we will wait until we consider a Connection to have timed out t...
true
25d772aa498c58267178cceaa7e005828368fb5c
Rust
gmorer/REST_API
/src/router/login.rs
UTF-8
766
2.671875
3
[]
no_license
use actix_web::{web, Responder}; use serde::Deserialize; use crate::tables::user::UserDb; #[derive(Deserialize, Debug)] struct RegisterBody { username: String, password: String } fn register(body: web::Json<RegisterBody>, user: web::Data<UserDb>) -> impl Responder { println!("body: {:?}", body); user.ins...
true
b8ad254177db5ccbfc0b61376d55358f67e55baa
Rust
rockingdice/mhrice
/src/msg.rs
UTF-8
5,316
2.59375
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::file_ext::*; use crate::hash::hash_as_utf16; use crate::rsz::Guid; use anyhow::*; use serde::*; use std::convert::TryFrom; use std::io::{Read, Seek}; #[derive(Debug, Serialize)] pub struct MsgAttributeHeader { pub j: i32, pub name: String, } #[derive(Debug, Serialize, Clone)] pub struct MsgEntry { ...
true
8fc50b5184c267f39a38684c62103c9d7946dc16
Rust
Anode194/cala
/src/internal/whoami.rs
UTF-8
2,840
3.03125
3
[ "MIT", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// This is one of the global contexts of Cala. This one is particularly fast because it // is read only, and multiple threads can read the data at the same time. /// User information. pub struct User { /// User's desktop environment. pub env: &'static str, /// The user's host machine's name. pub host:...
true
72f27370b5088f2635ac20dfef232f1f9bf712fb
Rust
DeltaManiac/Weekend-Ray-Tracer
/src/material.rs
UTF-8
4,198
2.765625
3
[]
no_license
use crate::hitable::HitRecord; use crate::ray::Ray; use crate::sphere; use crate::vec3::Vec3; use rand::{thread_rng, Rng}; use std::rc::Rc; pub trait Material { fn scatter( &self, ray_in: &Ray, hit_record: &HitRecord, attenuation: &mut Vec3, scattered: &mut Ray, ) -> boo...
true
49c1e804f5598a8920c3d054911096988d442bf8
Rust
bumblepie/advent-of-code-2018
/day-23/part-2/src/main.rs
UTF-8
6,195
2.6875
3
[]
no_license
extern crate regex; #[macro_use] extern crate lazy_static; use std::cmp::Ordering; use std::collections::BinaryHeap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::process; use regex::Regex; fn main() { let args: Vec<String> = env::args().collect(); let filename = ...
true
a7677db017e44b8ee5d8d06ce4e7f04f512abdd7
Rust
bernard0ls/rust-rocket-web-service
/src/routes/post.rs
UTF-8
1,808
2.8125
3
[]
no_license
use rocket_contrib::json::{JsonValue, Json}; use crate::models::post::{Post, CreatePostReq, UpdatePostReq}; use crate::{DbConn}; #[get("/posts/get")] pub async fn get_posts(conn: DbConn) -> Result<JsonValue, JsonValue> { match Post::get_all(&conn).await { Ok(posts_vec) => Ok(json!({"posts": posts_vec})), ...
true
994c86c11a2afbf0abb78b9effcf486103740c9c
Rust
uazu/stakker_tui
/src/terminal.rs
UTF-8
10,041
2.875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::os_glue::Glue; use crate::{Features, Key, TermOut}; use stakker::{fwd, timer_max, Fwd, MaxTimerKey, Share, CX}; use std::error::Error; use std::mem; use std::panic::PanicInfo; use std::sync::Arc; use std::time::Duration; /// Actor that manages the connection to the terminal pub struct Terminal { resize:...
true
43b33112d52e1ddd7c609f0434434d1b469a5103
Rust
JiaboHou/rust_playground
/src/3-learn_rust/guessing_game/src/main.rs
UTF-8
1,488
3.890625
4
[]
no_license
// Make use of an external dependency called "rand" extern crate rand; // no need to "use rand;", this is done here. use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); // println!("The secret number is:...
true
84a61e2d7e70d11e10d0244039f049e6b0ae6559
Rust
puiterwijk/uefi-eventlog-rs
/src/parsed.rs
UTF-8
18,611
2.78125
3
[ "MIT" ]
permissive
use byteorder::{ByteOrder, LittleEndian}; use num_derive::FromPrimitive; use num_traits::FromPrimitive; use serde::Serialize; use std::{collections::HashMap, convert::TryInto}; use thiserror::Error; use uuid::Uuid; use crate::{serialize_as_base64, EventType, ParseSettings}; fn string_from_widechar(wchar: &[u8]) -> Re...
true
708ac8851691f5163e7965956e7d0ec4e5874157
Rust
arn-the-long-beard/proto-seeder
/src/writer/manager.rs
UTF-8
16,975
2.765625
3
[ "MIT" ]
permissive
//! Manage writing and update of content on files. use crate::{ content::{ guard::SeedGuard, module::{ import::{ImportModule, ParentModuleType}, SeedModule, }, view::SeedView, }, writer::{checker::Checker, FileOperation, ModulesWriter}, }; use indexmap...
true
5b6f20747c8e6e0fbd60681d9ea1aa28d79e462e
Rust
Krystian95/Holobook
/holobook/.cargo/registry/src/github.com-1ecc6299db9ec823/holochain_persistence_api-0.0.18/src/hash.rs
UTF-8
4,926
3.109375
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
//! The HashString type is defined here. It is used for type safety throughout the codebase //! to keep track of places where a string is the product of a hash function, //! and as a base type for Address to use. use crate::holochain_json_api::{error::JsonError, json::JsonString}; use multihash::{encode, Hash}; use ru...
true
9cca956245ce285677e81b7dd6dd5d104cc9303c
Rust
nevi-me/arrow2
/src/array/fixed_size_list/mutable.rs
UTF-8
5,088
2.84375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::sync::Arc; use crate::{ array::{ Array, MutableArray, MutableBinaryArray, MutablePrimitiveArray, MutableUtf8Array, Offset, }, bitmap::MutableBitmap, datatypes::DataType, error::{ArrowError, Result}, types::NativeType, }; use super::FixedSizeListArray; /// The mutable version ...
true
697554d6b3774234ea7ca0176b2ccf5958b71daa
Rust
DarthGandalf/advent-of-code
/2019/src/day8.rs
UTF-8
2,156
3.03125
3
[]
no_license
use crate::NoneError; use aoc_runner_derive::{aoc, aoc_generator}; use pest::Parser; #[derive(Parser)] #[grammar = "day8.pest"] struct Day8Parser; struct Row(Vec<u8>); struct Layer(Vec<Row>); struct Image(Vec<Layer>); #[aoc_generator(day8)] fn parse(input: &str) -> anyhow::Result<Image> { let input = Day8Parser::pa...
true
052348e572c0020eb1972544f6ff504c9a910805
Rust
seguidor777/dcoder-solutions
/easy/learning_strings_and_binary_numbers.rs
UTF-8
311
3.109375
3
[]
no_license
use std::io; fn main() { let mut input = String::new(); io::stdin() .read_line(&mut input) .expect("cannot read input"); let v: Vec<&str> = input.split_whitespace().collect(); match v[0].contains(v[1]) { true => println!("1"), false => println!("0"), } }
true
4e57ce83f84aae2f44d10322bac8753b435718db
Rust
cs4026/git_info
/src/main.rs
UTF-8
5,966
2.625
3
[]
no_license
#![feature(plugin)] #![plugin(rocket_codegen)] #[macro_use] extern crate serde_derive; extern crate git_info; extern crate rocket; extern crate serde; extern crate serde_json; extern crate rocket_cors; use std::{path::Path,fs}; use rocket::request::Request; use std::io::Cursor; use std::env; use rocket::response::...
true
5ee82a655395fc4664ea230e4820b5c8a1b47f85
Rust
lu-zero/rust-optimization-example
/src/main.rs
UTF-8
1,716
2.578125
3
[]
no_license
#[macro_use] extern crate itertools; extern crate time; extern crate lib; use time::PreciseTime; fn cmp(a: &[u8], b: &[u8]) { let ia = a.iter(); let ib = b.iter(); for (av, bv) in izip!(ia, ib) { if av != bv { println!("{} != {}", av, bv); } } } fn benchme<F>(name: &str, ...
true
f01e619de12863ee7422f429a90353833a01e758
Rust
JtotheThree/RustRogue
/src/sys/render.rs
UTF-8
1,106
2.734375
3
[]
no_license
use bear_lib_terminal::Color; use bear_lib_terminal::terminal::{self}; use constants::*; use components::{Sprite, Position}; use specs::{ReadStorage, System}; pub struct Render; impl<'a> System<'a> for Render { type SystemData = (ReadStorage<'a, Position>, ReadStorage<'a, Sprite>); fn ...
true
71d1ec5c73222d63ce6f2c64736905007908f4e0
Rust
sh0623k/coding_interview
/src/bin/ch02p06.rs
UTF-8
1,576
3.3125
3
[]
no_license
/* 問題: 連結リストが回文かどうかを調べる関数を実装する。 */ extern crate coding_interview; use coding_interview::linked_list::*; fn is_palindrome(list: LinkedList<i32>) -> bool { let mut node_backward; let mut iterator_back = list.iter_backward(); for node_forward in list.iter() { node_backward = iterator_back.next(); ...
true
3a85c8265fa5e1abc3ccfa7e71bcff8c03afc618
Rust
rust-lang/odht
/src/memory_layout.rs
UTF-8
11,189
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{ borrow::{Borrow, BorrowMut}, convert::TryInto, marker::PhantomData, mem::{align_of, size_of}, }; use crate::{ error::Error, raw_table::{Entry, EntryMetadata, RawTable}, Factor, }; use crate::{swisstable_group_query::REFERENCE_GROUP_SIZE, Config}; const CURRENT_FILE_FORMAT_VERSIO...
true
f9480e35ccf968e5d0f2bd8c7067896ab1c1fccb
Rust
TGElder/isometric
/src/event_handlers/shutdown.rs
UTF-8
1,119
2.640625
3
[]
no_license
use engine::{Command, Event}; use events::EventHandler; use std::sync::Arc; pub struct ShutdownHandler {} impl ShutdownHandler { pub fn new() -> ShutdownHandler { ShutdownHandler {} } } impl EventHandler for ShutdownHandler { fn handle_event(&mut self, event: Arc<Event>) -> Vec<Command> { ...
true
aadc6459467ae08e0ac61c20ff1d52dac9105e7b
Rust
casey/janus
/src/error.rs
UTF-8
1,131
2.515625
3
[]
no_license
use crate::common::*; #[derive(Debug)] pub enum Error { Reqwest(reqwest::Error), InvalidHeaderValue(http::header::InvalidHeaderValue), Io(io::Error), Serde(serde_yaml::Error), Pattern(glob::PatternError), Glob(glob::GlobError), Status(http::StatusCode), Empty, } impl From<reqwest::Error> for Error { ...
true
435461380a32ea395958cab0a7d831e4f6113b53
Rust
NashFP/computer-chess
/jorendorff+rust/src/main.rs
UTF-8
1,860
2.71875
3
[]
no_license
#![warn(rust_2018_idioms)] mod minimax; mod interactive_play; mod pennies; mod fifteen; mod othello; mod chess; mod xboard; use crate::{ interactive_play::play_human_vs_computer, xboard::play_xboard, minimax::Game, minimax::best_move, pennies::Pennies, fifteen::Fifteen, othello::Othello, ...
true
ed4cadb2c33e08c336a9c8faaebf5fc3268cbfe8
Rust
Manishearth/triomphe
/src/arc.rs
UTF-8
35,198
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use alloc::alloc::handle_alloc_error; use alloc::boxed::Box; use core::alloc::Layout; use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::ffi::c_void; use core::fmt; use core::hash::{Hash, Hasher}; use core::iter::FromIterator; use core::marker::PhantomData; use core::mem::{ManuallyDrop, Maybe...
true
e8d9f7188de7f29f93229bdf830de18b853025a3
Rust
rodya-mirov/radishes
/src/systems/render_gas_system.rs
UTF-8
1,839
2.609375
3
[]
no_license
use std::sync::Arc; use legion::*; use web_sys::ImageBitmap; use crate::{ assets::{Assets, ImageBitmapExt}, canvas_util::CanvasState, resources::*, tile_helpers::{TILE_HEIGHT_PIXELS, TILE_WIDTH_PIXELS}, }; use super::map_render_helpers::{get_map_render_data, MapRenderData}; const MAX_GAS_ALPHA: f64...
true
7b9cca631c205653c2763b06c4465a7a82374cd1
Rust
steigr/asciii
/src/project/computed_field.rs
UTF-8
3,500
3.046875
3
[]
no_license
use util; use storage::Storable; use super::Project; use super::spec::*; /// Fields that are accessible but are not directly found in the file format. /// This is used to get fields that are computed through an ordinary `get("responsible")` custom_derive! { #[derive(Debug, IterVariants(ComputedFields...
true
57aaf27210a45a105f92aa8088da18ec9c50edcd
Rust
halzy/twitch_api2
/src/helix/channels/modify_channel_information.rs
UTF-8
5,960
3.390625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Modify channel information for users. //! [`modify-channel-information`](https://dev.twitch.tv/docs/api/reference#modify-channel-information) //! //! # Accessing the endpoint //! //! ## Request: [ModifyChannelInformationRequest] //! //! To use this endpoint, construct a [`ModifyChannelInformationRequest`] with the ...
true
918a326e87eb882ce7bcef5c02aff42e04b845aa
Rust
seanwallawalla-forks/nushell
/crates/nu-protocol/src/return_value.rs
UTF-8
4,971
3.15625
3
[ "MIT" ]
permissive
use crate::{value::Value, ConfigPath}; use nu_errors::ShellError; use nu_source::{DbgDocBldr, DebugDocBuilder, PrettyDebug}; use serde::{Deserialize, Serialize}; /// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command its...
true
e6844fe8997e00186e8e2fae07ee1ee11fc062c3
Rust
tsal/jirac
/src/v2/issue_link.rs
UTF-8
2,852
3.484375
3
[]
no_license
//! A representation of JIRA's issue link format // ============================================================================ // Use // ============================================================================ use crate::v2::{Issue, IssueLinkType}; use crate::Client; use crate::Response; use crate::{Deserialize,...
true
533bc7a921c30b3207aa440b76507bf4a5828fb6
Rust
wfdewith/embedded-mqtt
/src/variable_header/connect.rs
UTF-8
6,679
2.65625
3
[ "MIT" ]
permissive
use core::{ convert::{From, TryFrom, TryInto}, fmt::Debug, result::Result, }; use crate::{ codec::{self, Encodable}, error::{DecodeError, EncodeError}, fixed_header::PacketFlags, qos, status::Status, }; use super::HeaderDecode; use bitfield::BitRange; #[derive(PartialEq, Eq, Debug, C...
true
82c59f59909e80b57ddd62c864acd5513a5b6dfd
Rust
AlexEne/wasm_interp
/wasm/src/reader/scoped_reader.rs
UTF-8
975
3.015625
3
[ "MIT" ]
permissive
use std::io; use std::io::prelude::*; pub struct ScopedReader<'a, I: io::Read> { src: &'a mut I, offset: usize, size: usize, } impl<'a, I> ScopedReader<'a, I> where I: Read, { pub fn new(src: &'a mut I, size: usize) -> Self { Self { src, offset: 0, size,...
true
a534734a66704d64e1f6947aefd27ed9e870f22e
Rust
hummans/feeless
/src/rpc/client/cli.rs
UTF-8
2,666
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate::rpc::calls::RpcCommand; use crate::rpc::client::{RPCClient, RPCRequest}; use clap::Clap; use colored_json::ToColoredJson; use serde::Serialize; #[derive(Clap)] pub(crate) struct RPCClientOpts { /// The URL of the RPC server. #[clap( long, short, default_value = "http://localh...
true
5bebf8e45109e8d5d96c1ca157569ff0c33b3a04
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-13204.rs
UTF-8
575
3.234375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(unused_mut)] // Test that when instantiating trait default methods, typeck handles // lifetime parameters defined on the method bound correctly. pub trait Foo { fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize { let mut xs = it.filter(|_| true); xs.count() } } ...
true
e87ffcefccd1e6f7ab4b0c798124bc1a45d90943
Rust
sam701/syconf
/syconf-bin/src/main.rs
UTF-8
2,848
2.8125
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::{Read, Write}; use std::{env, io}; use clap::{App, Arg}; use tracing_subscriber::EnvFilter; use syconf_lib::SerializableValue; fn main() { let matches = App::new("syconf") .version(env!("CARGO_PKG_VERSION")) .about("syconf converts syconf files into JSON/YAML/TOML"...
true
09968e6337c48db3f6c0ed5fb8c63bd3a3e19a61
Rust
isgasho/RustNAO
/examples/simple_example.rs
UTF-8
625
2.953125
3
[ "MIT" ]
permissive
//! A simple example, assuming you had a config.json file that had your api key. use rustnao::{HandlerBuilder, Sauce}; fn main() { let data = std::fs::read_to_string("config.json").expect("Couldn't read file."); let json: serde_json::Value = serde_json::from_str(data.as_str()).expect("JSON not well formatted."); l...
true
87034cbca31aa63b52b5fdb08f46e0d70668d1d9
Rust
AldaronLau/footile
/src/geom.rs
UTF-8
13,052
3.578125
4
[ "MIT", "Apache-2.0" ]
permissive
// geom.rs Simple geometry stuff. // // Copyright (c) 2017-2018 Douglas P Lau // use std::f32; use std::ops; /// 2-dimensional vector. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Vec2 { pub x: f32, pub y: f32, } /// 2-dimensional vector with associated width. #[derive(Clone, Copy, Debug, PartialEq...
true
94270299f43c0dfe9f024881a97ab30c3c78b1f2
Rust
igiagkiozis/plotly
/plotly/src/layout/update_menu.rs
UTF-8
12,167
3.09375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Buttons and Dropdowns. use plotly_derive::FieldSetter; use serde::Serialize; use serde_json::{Map, Value}; use crate::{ color::Color, common::{Anchor, Font, Pad}, Relayout, Restyle, }; /// Sets the Plotly method to be called on click. If the `skip` method is used, /// the API updatemenu will function...
true
1841513d8c8ceb265930c6bdc7c0b283a239bcd1
Rust
playaround88/kvs
/src/bin/kvs-server.rs
UTF-8
2,363
2.59375
3
[]
no_license
use kvs::{KvStore, KvsEngine, Result}; use std::env::current_dir; use std::io::{Read, Write}; use std::net::{Shutdown, TcpListener, TcpStream}; extern crate clap; #[macro_use] extern crate log; extern crate stderrlog; use clap::{App, Arg}; //use log::{LevelFilter, SetLoggerError}; //use stderrlog::StdErrLog; fn main...
true
534a19c56cbbfe5912c455cbfc08d46468d35006
Rust
commune-ai/tendermint-light-client
/src/merkle_tree.rs
UTF-8
2,301
3.484375
3
[ "Apache-2.0" ]
permissive
//! Merkle tree used in Tendermint networks use sha2::{Digest, Sha256}; /// Size of Merkle root hash pub const HASH_SIZE: usize = 32; /// Hash is the output of the cryptographic digest function pub type Hash = [u8; HASH_SIZE]; /// Compute a simple Merkle root from vectors of arbitrary byte vectors. /// The leaves o...
true
c0c750a938be96872d425faae3bf32e958d19d19
Rust
snicmakino/competitive-programming-ant
/src/q2_2_1.rs
UTF-8
497
3.015625
3
[]
no_license
mod q2_2_1 { pub fn solve(c: Vec<i32>, mut a: i32) -> i32 { use std::cmp::min; let v = [1, 5, 10, 50, 100, 500]; let mut ans = 0; for i in (1..6).rev() { let t = min(a / v[i], c[i]); a -= t * v[i]; ans += t; } ans } } #[cfg(te...
true
63d98fed0703f95ef5d46067a8308a94e6b8f9b8
Rust
nimiq/core-rs
/client/src/static_env.rs
UTF-8
1,423
3.28125
3
[ "Apache-2.0" ]
permissive
use std::cell::UnsafeCell; use std::mem; use parking_lot::Mutex; use database::Environment; /// A wrapper for static variables that can be initialized at run-time /// Invariants are checked dynamically, i.e. it will panic if you try to get a static reference /// if the variable wasn't initialized yet or if you try t...
true
fcb92195fef397c18bdc911c0d5b86b2ee96146d
Rust
section77/snippets
/src/snippet.rs
UTF-8
1,192
3.25
3
[]
no_license
//! models snippets use chrono::serde::ts_seconds; use chrono::{DateTime, Utc}; use rocket::http::RawStr; use rocket::request::FromFormValue; use serde::{Deserialize, Serialize}; pub type SnippetId = u64; #[derive(Debug, Serialize, Deserialize)] pub struct Snippet { pub id: SnippetId, #[serde(with = "ts_secon...
true
a2a0bc9d0fcbf7fe8c6984fae0d1daba2ab60080
Rust
cpdt/inkwell
/src/context.rs
UTF-8
12,168
2.515625
3
[ "Apache-2.0" ]
permissive
use llvm_sys::core::{LLVMAppendBasicBlockInContext, LLVMContextCreate, LLVMContextDispose, LLVMCreateBuilderInContext, LLVMDoubleTypeInContext, LLVMFloatTypeInContext, LLVMFP128TypeInContext, LLVMInsertBasicBlockInContext, LLVMInt16TypeInContext, LLVMInt1TypeInContext, LLVMInt32TypeInContext, LLVMInt64TypeInContext, LL...
true
edf1d50cf303fa432534f26888672fac9569a717
Rust
procuteboy/inko
/vm/src/immix/copy_object.rs
UTF-8
7,728
3.40625
3
[]
no_license
//! Copying Objects //! //! The CopyObject trait can be implemented by allocators to support copying of //! objects into a heap. use block::Block; use object::Object; use object_value; use object_value::ObjectValue; use object_pointer::ObjectPointer; pub trait CopyObject: Sized { /// Allocates a copied object. ...
true
ea75fb5465bc71aeb90974047d61c96cd5e1df20
Rust
frjonsen/aoc2020
/src/day16.rs
UTF-8
5,275
3.015625
3
[]
no_license
use itertools::Itertools; use regex::{Match, Regex}; use std::ops::RangeInclusive; struct Rule { name: String, interval_one: RangeInclusive<u32>, interval_two: RangeInclusive<u32>, } struct Input { rules: Vec<Rule>, personal_ticket: Vec<u32>, nearby_tickets: Vec<Vec<u32>>, } fn parse_range(m:...
true
d5ed2281e60a01f39894f28086c673bb2eeff5bb
Rust
neetjn/rust-beers
/practice/string.rs
UTF-8
775
3.734375
4
[ "MIT" ]
permissive
fn main() { // reference to a string located in read-only memory let p: &'static str = "the quick brown fox jumps over the lazy dog"; println!("Pangram: {}", p); // iterate over words // - can alternatively use `split_whitespace` for s in p.split(' ') { println!("> {}", s); } // mutable string let...
true
cc149977197d49dd695ee97d8a17592f7ecf4780
Rust
nuxlli/bo
/tests/main.rs
UTF-8
1,860
2.78125
3
[ "MIT" ]
permissive
use assert_cmd::Command; use predicates::prelude::*; // Used for writing assertions use std::io::Write; use tempfile::NamedTempFile; const BIN: &'static str = env!("CARGO_PKG_NAME"); const VERSION: &'static str = env!("CARGO_PKG_VERSION"); const NAME: &'static str = env!("CARGO_PKG_NAME"); const DESCRIPTION: &'static...
true
4de4f335861c247c42dbf7228ff852ec1dbffa10
Rust
brooks-builds/zombie_simulator
/src/components/speed.rs
UTF-8
284
3.171875
3
[]
no_license
use std::ops::Deref; #[derive(Debug, Copy, Clone)] pub struct Speed(pub f32); impl Speed { pub fn set(&mut self, new_speed: f32) { self.0 = new_speed; } } impl Deref for Speed { type Target = f32; fn deref(&self) -> &Self::Target { &self.0 } }
true
30b27d539f09312561cf5fa527d93e5533f8e9ea
Rust
virtualritz/simdeez
/src/scalar/overloads.rs
UTF-8
16,421
2.96875
3
[ "MIT" ]
permissive
use super::*; // -- AddAssign impl AddAssign for I16x1 { #[inline(always)] fn add_assign(&mut self, rhs: I16x1) { *self = I16x1(self.0 + rhs.0); } } impl AddAssign for I32x1 { #[inline(always)] fn add_assign(&mut self, rhs: I32x1) { *self = I32x1(self.0 + rhs.0); } } impl AddAs...
true
bb691173fc360d26dc87d731bbd248482ec70de1
Rust
hopv/hoice
/src/unsat_core.rs
UTF-8
1,898
3.046875
3
[ "Apache-2.0" ]
permissive
//! Unsat core and proof extraction. //! //! Right now, only unsat proof in the form of [`entry_points`] is active. //! //! [`entry_points`]: entry_points/index.html (entry_points module) use crate::common::*; pub mod entry_points; mod sample_graph; pub use self::entry_points::Entry; /// An unsat result. pub enum U...
true
ba4ac10790487d3b2593a63a0701aab423f5db1d
Rust
dimforge/ncollide
/src/pipeline/object/collision_groups.rs
UTF-8
13,457
3.265625
3
[ "Apache-2.0" ]
permissive
use crate::pipeline::broad_phase::BroadPhasePairFilter; use crate::pipeline::object::{CollisionObjectRef, CollisionObjectSet}; use na::RealField; const SELF_COLLISION: u32 = 1 << 31; const ALL_GROUPS: u32 = (1 << 30) - 1; const NO_GROUP: u32 = 0; /// Groups of collision used to filter which object interact with which...
true
ccc73b78bd91af96a7d76c944072c56c1e3253e2
Rust
umurgdk/soundlines
/soundlines_core/src/db/models/weather.rs
UTF-8
796
3.03125
3
[]
no_license
use postgres::rows::Row; use postgres::types::ToSql; use db::Result as DbResult; use db::Connection; use db::extensions::*; #[derive(Debug, Clone, Serialize)] pub struct Weather { #[serde(skip)] pub id: i32, pub temperature: f64, pub precip: Option<String> } impl Weather { pub fn get(conn: &Connection) -> DbRes...
true
101f850cdef27974ee3ad0827ad3cbe401ac9ec3
Rust
cajoho99/aoc-2020
/src/day02/mod.rs
UTF-8
2,015
3.140625
3
[]
no_license
use crate::lib::Solver; pub struct Day2Solver; impl Solver for Day2Solver { fn solve(&self, lines: &[String], part_two: bool) -> String { let mut counter = 0; for line in lines { let first_split: Vec<&str> = line.split(|c| c == ':').collect(); let password = first_split[1].trim(); let s_split: Vec<&str>...
true
6790e1c2cd2512b0f5bca705da5095cd98b98172
Rust
enbugger/smooth-bevy-cameras
/src/look_angles.rs
UTF-8
4,753
3.28125
3
[ "MIT" ]
permissive
use approx::relative_eq; use bevy::math::prelude::*; const PI: f32 = std::f32::consts::PI; /// A (yaw, pitch) pair representing a direction. #[derive(Clone, Copy, Debug, Default)] pub struct LookAngles { // The fields are protected to keep them in an allowable range for the camera transform. yaw: f32, pit...
true
5da5d96df1befa242c6618e3c3e01a87a9f7a042
Rust
i25959341/rust-lightning
/fuzz/fuzz_targets/msg_targets/utils.rs
UTF-8
1,521
2.75
3
[ "Apache-2.0" ]
permissive
#![macro_use] #[allow(dead_code)] #[inline] pub fn slice_to_be16(v: &[u8]) -> u16 { ((v[0] as u16) << 8*1) | ((v[1] as u16) << 8*0) } #[macro_export] macro_rules! test_msg { ($MsgType: path, $data: ident, $read_pos: ident) => { { let len = slice_to_be16(get_slice!($data, $read_pos, 2)); let raw = get_slice...
true
6b81279ba6b3f9b003a53b2bc11bfdb981ae24c9
Rust
qqx3d/qqx3d.github.io
/examples/triangle.rs
UTF-8
884
2.515625
3
[]
no_license
#[qqx::qqx(polygon)] struct Vertex { pos: qqx::Vec2 <f32>, color: qqx::Color } fn main() { let window = qqx::Window::new().build(); let triangle = qqx::Polygon::new().vertex(Vertex::new() .pos(qqx::Vec2::new(-0.5, -0.5)) .color(qqx::Color::RED)) .vertex(Vertex::new() .pos(q...
true
26f44ff3509c21965c452cf977004677ddb92dd5
Rust
cout970/raytrace-rs
/src/raytrace.rs
UTF-8
2,397
3.09375
3
[ "MIT" ]
permissive
use cgmath::InnerSpace; use material::ScatterResult; use scene::Scene; use solids::Solid; use std::cmp::Ord; use std::cmp::Ordering::Equal; use std::f32::MAX; use util::randf; use util::Vector3f; use material::Materials; pub struct Ray { pub origin: Vector3f, pub dir: Vector3f, pub t_min: f32, pub t_ma...
true
dc55e62c14d60e3ee983f1380a1a66b11f0dfac7
Rust
ChaiTRex/advent-of-code-2019
/rust/day10/src/main.rs
UTF-8
1,794
2.828125
3
[ "MIT" ]
permissive
use day10::Vector; use itertools::Itertools; use std::{ fs::File, io::{BufRead, BufReader}, }; fn main() { let asteroids = (0i32..) .zip( BufReader::new(File::open("../10.txt").unwrap()) .lines() .map(Result::unwrap), ) .map(|(y, line)| { ...
true
f5fbe12de3735fd35db75e9f66e823715f1a7637
Rust
hnOsmium0001/aoc-2019
/day10.rs
UTF-8
1,778
3.3125
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; #[derive(Debug, PartialEq, Eq)] struct Point { x: i32, y: i32, } fn read_asteroids() -> (Vec<Vec<char>>, Vec<Point>, i32, i32) { let file = File::open("inputs/day10.txt").expect("No input.txt"); let buf = BufReader::new(file); let lines: Ve...
true
d0e8f99085f2cfb9d25873c13c31c06abf4c06f0
Rust
reillysiemens/imagr-ng
/src/main.rs
UTF-8
5,246
2.546875
3
[]
no_license
use std::env; use std::fmt; use std::path::PathBuf; use futures::{SinkExt, StreamExt, TryStreamExt}; use serde::de::DeserializeOwned; use serde_derive::Deserialize; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio_util::codec::{BytesCodec, FramedWrite}; #[derive(Debug, Deserialize)] #[serde(bound = "T: fm...
true
c39354c8f01d297004bd42e077ffc3763d6abd93
Rust
cdbfoster/advent_of_code_2020
/src/bin/d21p1.rs
UTF-8
1,603
2.640625
3
[]
no_license
extern crate advent_of_code; extern crate regex; use std::collections::{HashMap, HashSet}; use regex::Regex; use advent_of_code::read_input_list; fn main() { let input: Vec<String> = read_input_list().unwrap(); let food = Regex::new(r"^((?:\w+ )*?\w+) \(contains ((?:\w+, )*?\w+)\)$").unwrap(); let foo...
true
1d63bdfd6a6c2fbca3223f9e6cd5ae5732a096cf
Rust
DhruvDh/memory-bench
/retry/src/main.rs
UTF-8
5,092
2.734375
3
[]
no_license
#![feature(core_intrinsics, asm)] use std::time::Instant; use packed_simd::{u64x4}; use std::thread; use std::fmt; const NUM_LOOPS_1: usize = 100_000; const NUM_LOOPS_2: usize = 10_000; const NUM_LOOPS_3: usize = 1_000; const NUM_LOOPS_4: usize = 100; const START_SIZE: usize = 2; const UP_TO: usize = 23; const NUM_T...
true
49c8665b3e034636f70e137b672536b3a65a95cc
Rust
adriangligor/octoplex
/src/http_client.rs
UTF-8
2,506
2.71875
3
[ "Apache-2.0" ]
permissive
use async_trait::async_trait; use anyhow::{Result, Context}; use http::Response; use hyper::{Client, Request, Body}; use hyper::client::HttpConnector; use hyper::client::connect::dns::GaiResolver; use hyper_tls::HttpsConnector; use native_tls::TlsConnector; // the purpose of this trait is to decouple dependent code fr...
true
3a4402001d394841f87fa3e15df8d24d347fe1a5
Rust
waywardmonkeys/elasticsearch-rs
/codegen/src/gen/rust/ty.rs
UTF-8
2,922
3.015625
3
[ "Apache-2.0" ]
permissive
use std::intrinsics::type_name; use syntax::ast::*; use syntax::parse::token; use syntax::codemap::DUMMY_SP; use syntax::ptr::P; use super::parse::parse_path; /// Generate a type with a specified name. pub fn build_ty(name: &str) -> Ty { Ty { id: DUMMY_NODE_ID, node: TyKind::Path(None, build_path(name)), span: ...
true
1d7e78e37413e9d762934e5b1e29419ee5a4b823
Rust
crosstyan/mican
/src/parser.rs
UTF-8
4,681
2.9375
3
[ "MIT" ]
permissive
use nix::unistd::pipe; use token::{CommandData, Token, Input}; use std::fs; use std::os::unix::io::{FromRawFd, RawFd}; use std::io; const PIPE: char = '|'; pub struct Parser { pub pos: usize, pub input: String, pub pipes: Vec<(RawFd, RawFd)>, } impl Parser { pub fn new(input_: String) -> Self { ...
true
b395486cc29e56f740e3e9087737ebd863b26c6f
Rust
zenixls2/tokio-lk
/benches/lock1000_serial.rs
UTF-8
755
2.828125
3
[ "MIT" ]
permissive
#![feature(test)] extern crate test; use std::collections::HashMap; use std::sync::{Arc, Mutex, RwLock}; use std::time::Instant; use test::Bencher; #[bench] fn test_lock1000_serial(_b: &mut Bencher) { let map = Arc::new(RwLock::new(HashMap::new())); let now = Instant::now(); let mut wmap = map.write().unwr...
true
9a90e20cff914c7efe6309754f80489a4fe7d826
Rust
sotrh/learn-wgpu
/code/showcase/lost-window/src/main.rs
UTF-8
4,285
2.5625
3
[ "MIT" ]
permissive
use std::time::{Duration, Instant}; use winit::{ event::{Event, WindowEvent}, event_loop::EventLoop, window::WindowBuilder, }; async fn run() -> anyhow::Result<()> { let event_loop = EventLoop::new(); let mut window = Some( WindowBuilder::new() .with_visible(false) ...
true
00bb0a43dfe547ffb0aa01f349b1181fbd062c94
Rust
cakebaker/rlox
/src/token_type.rs
UTF-8
2,680
3.640625
4
[ "MIT" ]
permissive
use std::fmt; #[derive(Clone, Debug, PartialEq)] pub enum TokenType { // Single-character tokens LeftParen, RightParen, LeftBrace, RightBrace, Comma, Dot, Minus, Plus, Semicolon, Slash, Star, // One or two character tokens Bang, BangEqual, Equal, Equ...
true
c8a2d38105e6c17c66804383b6a77e39b23aab38
Rust
JetHalo/ShamirSecret_Share
/src/shamir_secret.rs
UTF-8
8,095
3.3125
3
[]
no_license
use crate::ff_gf256::GF256; use crate::lagrange_interpolation::barycentric_interpolate; use crate::polynomial::Polynomial; use crate::Field; use rand::{thread_rng, Rng}; use subtle::ConstantTimeEq; /// Represents a set of points which make up a share of a secret pub struct Share<Fq: Field> { points: Vec<(Fq, Fq)>,...
true
f25268a803e92697722f2fbd7c9d54b41acaae9c
Rust
rust-lang/rust-analyzer
/crates/syntax/src/ast/generated/tokens.rs
UTF-8
6,101
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Generated by `sourcegen_ast`, do not edit by hand. use crate::{ ast::AstToken, SyntaxKind::{self, *}, SyntaxToken, }; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Whitespace { pub(crate) syntax: SyntaxToken, } impl std::fmt::Display for Whitespace { fn fmt(&self, f: &mut std::fmt::F...
true
964a7e6ae8608eedf088b72abca107d12cfdfb03
Rust
TimHambourger/julia-wasm
/wasm/julia/src/canvas.rs
UTF-8
2,829
3.296875
3
[ "MIT" ]
permissive
use num_complex::{Complex,Complex32}; /// An unbounded canvas divided into chunks. /// Chunks carry a size in px and in complex coords, and canvas /// is marked with an origin that specifies how chunks are aligned #[derive(PartialEq, Copy, Clone)] pub struct Canvas { pub chunk_width_px : usize, pub chunk_heigh...
true
bd747db20a75bb914de6c060e6b719eab3d44773
Rust
Lehona/Parsiphae
/src/parsers/exp/binary.rs
UTF-8
4,398
3.234375
3
[ "MIT" ]
permissive
use inner_errors::ParserError; use parsers::Unary; use types::PResult; use types::{BinaryExpression, BinaryOperator, Expression, Input}; pub fn Boolean(input: Input) -> PResult<Expression> { left_associative_binary(one_of_tag!("||", "&&"), Cmp)(input) } pub fn Cmp(input: Input) -> PResult<Expression> { left_a...
true
0779f8c5b17a21158cc36a8b3a8c74c0aa4e046e
Rust
Ppjet6/zeerust
/src/cpu/opcodes/index.rs
UTF-8
666
2.59375
3
[ "Apache-2.0" ]
permissive
use crate::cpu::opcodes::util::*; use crate::ops::{Location16, Op, Reg16}; pub fn parse(reg: Reg16, op: u8, n1: u8, n2: u8) -> (Op, usize) { match op { 0x21 => (Op::LD16(Location16::Reg(reg), le_immediate(n1, n2)), 4), 0x2A => (Op::LD16(Location16::Reg(reg), le_imm_indir(n1, n2)), 4), 0x22 ...
true
303dea55cfe118e03dba56fc9eb06e202a26c2e1
Rust
gituser9/RssReader
/Services/vk_service/src/api_service.rs
UTF-8
2,401
3.078125
3
[]
no_license
use reqwest; use std::io::Read; use serde_json; use serde_json::Value; use serde_json::map::Map; use model::json_models::AppSettings; #[derive(Debug)] pub struct ApiService<'a> { settings: &'a AppSettings, } impl<'a> ApiService<'a> { pub fn new(settings: &'a AppSettings) -> ApiService { ApiService ...
true
e185c81448859530543b6f835fcd4da7ad2df256
Rust
Ithariel/adminpw-rs
/src/panel/liveconfig.rs
UTF-8
3,333
2.90625
3
[ "Unlicense" ]
permissive
use std::io::{BufRead, BufReader}; use std::fs::File; use async_std::task; use sqlx::Connection; use sqlx::any::AnyConnection; use sqlx::any::AnyQueryResult; const CONFIG: &str = "/etc/liveconfig/liveconfig.conf"; pub fn is_liveconfig() -> bool { if std::path::Path::new(CONFIG).exists() { return true; ...
true
52d87fec81c942c05e6fc4f4b063ef2eb626d0f7
Rust
mrnix/rust_d3_geo
/src/path/string.rs
UTF-8
3,259
3.046875
3
[]
no_license
use std::fmt::Display; use std::string::String as S; use geo::{CoordFloat, Coordinate}; use crate::stream::Stream; use super::PointRadiusTrait; use super::{Result, ResultEnum}; #[derive(Clone, Debug)] enum PointState { LineAtStart, LineInProgress, LineNotInProgress, } #[inline] fn circle<T>(radius: T) ...
true
eb3116ee375705f63feaf21ad29ffdaeb662fb74
Rust
actix/actix-web
/awc/src/responses/response_body.rs
UTF-8
4,097
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{ future::Future, mem, pin::Pin, task::{Context, Poll}, }; use actix_http::{error::PayloadError, header, HttpMessage}; use bytes::Bytes; use futures_core::Stream; use pin_project_lite::pin_project; use super::{read_body::ReadBody, ResponseTimeout, DEFAULT_BODY_LIMIT}; use crate::ClientRespons...
true
395202567ea7bb31ac5e4ba3ad630001b30de232
Rust
Garvys/rustfst
/rustfst/src/algorithms/lazy/cache/cache_internal_types.rs
UTF-8
2,554
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cmp::Eq; use std::collections::HashMap; use std::hash::Hash; use crate::algorithms::lazy::CacheStatus; use crate::semirings::Semiring; use crate::{StateId, TrsVec}; pub type StartState = Option<StateId>; pub type FinalWeight<W> = Option<W>; #[derive(Debug, Clone, PartialEq, Eq)] pub struct CacheTrs<W: Semir...
true
1ec97c2b67a6de61f8e18a2d7843d2e248c6c85c
Rust
Oleksii-Kshenskyi/04_trees_in_rust
/a_binary_tree/src/main.rs
UTF-8
1,238
3.5625
4
[ "Unlicense" ]
permissive
use tree::BinaryTree; mod tree; // Binary tree should implement these operations: // - Find element; // - Insert element; // - Remove element. fn s(s: &str) -> String { s.to_string() } fn main() { let mut tree = BinaryTree::<String, String>::new(); tree.insert(s("One"), s("1")); assert_eq!(Some(s("1...
true
03886d40388726a0891cc97277e8579af803faec
Rust
eightys3v3n/word_processor
/src/file_system.rs
UTF-8
8,241
3.234375
3
[]
no_license
use std::error::Error; use std::fs; use std::io; use std::io::prelude::*; use std::path::PathBuf; use std::vec::Vec; pub fn list_files(root: &PathBuf, recursive: bool) -> Vec<PathBuf> { let mut files: Vec<PathBuf> = Vec::<PathBuf>::new(); for res in fs::read_dir(root).unwrap() { let path = match res {...
true
a69449057c79c8114930ed1d1cf7ebe8c55df291
Rust
marco-c/gecko-dev-wordified
/third_party/rust/fluent-syntax/src/parser/slice.rs
UTF-8
553
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std : : ops : : Range ; pub trait Slice < ' s > : AsRef < str > + Clone + PartialEq { fn slice ( & self range : Range < usize > ) - > Self ; fn trim ( & mut self ) ; } impl < ' s > Slice < ' s > for String { fn slice ( & self range : Range < usize > ) - > Self { self [ range ] . to_string ( ) } fn trim ( & mut self...
true
9678b03241f2cb85880671e514e19b742d96ac91
Rust
DTomusk/Rust-Exercises
/fibonacci/src/main.rs
UTF-8
1,148
3.59375
4
[]
no_license
use std::io; fn fibonacci(n: i64) -> i64 { let base_array = [[1, 1], [1, 0]]; let mut result_array = base_array.clone(); for _x in 1..n { result_array = multiply_matrices(result_array, base_array); } result_array[0][1] } // could generalise for arrays of any size, but for our purposes we'l...
true