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
f097bb622916d656069742e4fc187e743ce478a4
Rust
akadata/IFRExtractor-RS
/src/main.rs
UTF-8
74,757
2.890625
3
[ "BSD-2-Clause" ]
permissive
// Parser #[macro_use] extern crate nom; pub mod parser; // Main use std::collections::HashMap; use std::fs::File; use std::fs::OpenOptions; use std::ffi::OsStr; use std::ffi::OsString; use std::io::prelude::*; use std::io::Write; use std::path::Path; const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSI...
true
5b6f7480c03f323e9035f699ec0defcdc5d72eea
Rust
allevo/bravery_router
/src/lib.rs
UTF-8
5,213
3.359375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Bravery router //! //! A radix tree implementation in rust without unsafe code //! //! ``` //! use bravery_router::{create_root_node, add, optimize, find}; //! //! let mut root = create_root_node(); //! add(&mut root, "/foo", 1); //! add(&mut root, "/users/:userId", 2); //! add(&mut root, "/*", 3); //! //! let root...
true
123225900f89f7a37dc3c68b5ddae7fcef2b7897
Rust
iptq/ui
/src/window.rs
UTF-8
352
3.09375
3
[ "MIT" ]
permissive
use failure::Error; /// An abstract Window. This trait is implemented by backend-specific window implementations. pub trait WindowExt: Sized { /// Creates a new instance of Window. fn new() -> Result<Self, Error>; /// Shows the window. fn show(&mut self); /// Change the title of the window. f...
true
e096a2267cf8672394bb5ad44c1b403771504e2f
Rust
oknozor/unicool
/unicool-web/src/lib.rs
UTF-8
1,359
3.015625
3
[]
no_license
extern crate unicool_lib; use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender}; pub struct Model { value: String, } pub enum Msg { GotInput(String), Save, } impl Component for Model { type Message = Msg; type Properties = (); fn create(_: Self::Properties, _: ComponentL...
true
473b8c8ebf5d32035056cd4abbc9e6a3ddff762c
Rust
0queue/boosttorrent-redux
/src/peer/job.rs
UTF-8
2,698
2.828125
3
[]
no_license
use std::cmp::min; use std::fmt::Debug; use std::fmt::Formatter; use sha1::Digest; use sha1::Sha1; use crate::controller::DownloadedPiece; use crate::controller::PieceMeta; use crate::protocol::BlockRequest; use crate::protocol::BlockResponse; const BLOCK_LENGTH: usize = 1 << 14; pub struct Job { pub piece: Pie...
true
73d5d2e3feea75bc0fa26b6bbdd1329b5df6697b
Rust
ItsHoff/Rusty
/src/color.rs
UTF-8
8,744
3.203125
3
[ "MIT" ]
permissive
use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Sub, SubAssign}; use cgmath::prelude::*; use cgmath::Vector3; use image::Pixel; use crate::consts; use crate::float::*; /// Convert u8 color to float color in range [0, 1] pub fn component_to_float(c: u8) -> Float { c.to_float() / s...
true
391e3dc4cb35e660ad7db5897e0eb447306745ac
Rust
yuanhongyu44/rurikawa
/judger/src/opt.rs
UTF-8
3,310
2.59375
3
[ "MIT" ]
permissive
use clap::Clap; use clap::{crate_authors, crate_license, crate_version}; use std::path::PathBuf; /// The judger client of the online judging platform Rurikawa OJ. #[derive(Clap, Debug, Clone)] #[clap( version = crate_version!(), author = crate_authors!(), license = crate_license!(), after_hel...
true
3f2df6efd7fa3ce51487c88bf7495543d7e86665
Rust
jneem/dfa-runner
/src/backtracking.rs
UTF-8
2,590
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2015 Joe Neeman. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to ...
true
81c4a41d91c3af6eb634adf1c1ffac4b11ac7f64
Rust
miguel-lattuada/edgedb-rust
/src/binarycodec/servermessage.rs
UTF-8
562
2.71875
3
[ "Apache-2.0" ]
permissive
use crate::protocol::{Serverhandshake, ErrorResponse}; pub enum ServerMessage { Serverhandshake(Serverhandshake), ErrorResponse(ErrorResponse) } impl ServerMessage { pub fn create(bytes: &[u8]) -> Result<ServerMessage, ()> { match bytes[0] { 0x78 => { let sh = Serverhan...
true
18389c88dfc040e7b91d7bcae6e37c0cb13dbf9d
Rust
BreD1810/rust-search-sort
/src/algorithms/gnome.rs
UTF-8
580
2.984375
3
[ "MIT" ]
permissive
use super::{Array, Algorithm}; pub struct GnomeSort; impl Algorithm for GnomeSort { fn run(&self, array: &Array) { let mut pos = 0; let len = array.len(); println!("Pos {}", pos); println!("Len: {}", len); while pos < len { if pos == 0 || array.get(pos) >= arra...
true
7793c6fa067a6d17fbc7c033840f3b6983c52889
Rust
k0pernicus/github-api-rs
/tests/test.rs
UTF-8
3,240
2.5625
3
[]
no_license
extern crate github; use github::client::GithubClient; use github::GetterAPI; use github::rate_limits::RateLimits; use github::repo::RepoClient; use std::env; use github::user::UserUpdateStructure; use github::UpdaterAPI; const DEFAULT_API_KEY: &'static str = "HelloWorld12345"; const DEFAULT_GITHUB_PROFILE: &'static ...
true
9b9d8a39cad699f074be89e1954e76d5d1b0de22
Rust
sharnoff/passman
/src/version/mod.rs
UTF-8
11,068
3.484375
3
[ "MIT" ]
permissive
//! Abstraction over multiple versions of the file format allowed //! //! Because we want to continue to properly handle old config file formats - even when they'll no //! longer be generated by default. In the future, we might provide some kind of feature-gating for //! older versions, so that the dependencies associa...
true
498918fc7c93d6223e9c675704bc36bfc19252c8
Rust
procuteboy/inko
/vm/src/bytecode_parser.rs
UTF-8
22,527
3.28125
3
[]
no_license
//! A parser for Inko bytecode streams //! //! This module provides various functions that can be used for parsing Inko //! bytecode files provided as a stream of bytes. //! //! To parse a stream of bytes you can use the `parse` function: //! //! let mut bytes = File::open("path/to/file.inkoc").unwrap().bytes(); //...
true
de02a362fbd65fc948bbb373ad16196a94e7fb12
Rust
jamshaidtahiri/RUST
/Runner-Up/src/main.rs
UTF-8
1,858
3.40625
3
[]
no_license
use std::io; fn main() { // io::stdin().read_line(& mut list) let mut list = vec![]; let mut x = String::new(); io::stdin().read_line(& mut x); let x=x.trim(); for i in 0..x.len(){ let y = &x[i..i+1]; let y : i32= y.parse().unwrap(); list.push(y) } // println!("{:?}",vecto...
true
9ba6a585e9e6f2bb9898b5e04914963c3befef7a
Rust
metrics-rs/quanta
/src/mock.rs
UTF-8
2,059
3.5
4
[ "MIT" ]
permissive
use crossbeam_utils::atomic::AtomicCell; use std::{sync::Arc, time::Duration}; /// Type which can be converted into a nanosecond representation. /// /// This allows users of [`Mock`] to increment/decrement the time both with raw /// integer values and the more convenient [`Duration`] type. pub trait IntoNanoseconds { ...
true
4de5f95e4126c5fc23d564ba670cdc9c18fc6d74
Rust
rotty/libzmq-rs
/libzmq/src/ctx.rs
UTF-8
14,737
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! The ØMQ context type. use crate::{auth::server::AuthServer, error::*}; use libzmq_sys as sys; use sys::errno; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use std::{ os::raw::{c_int, c_void}, ptr, str, sync::Arc, thread, }; lazy_static! { static ref GLOBAL_CONTEXT: Ctx ...
true
127362e8d71f7f877eadbfe0d7698199351a5412
Rust
fpiantini/rust_experiments
/snippets/using_traits/src/main.rs
UTF-8
3,107
3.734375
4
[ "MIT" ]
permissive
// On this example we define a set of 2-D objects // for which is possible to compute the area extern crate num_traits; use num_traits::pow; // ------------------------------------------------------ // THE TRAIT // The following trait define a measurability // characterist: an object is measurable if it // is possibl...
true
656c35158c9f2c6be9b4a8f99283703bc5b81984
Rust
CoolDeveloper101/colory
/examples/background.rs
UTF-8
1,447
2.984375
3
[ "Apache-2.0" ]
permissive
/* Copyright 2020 CoolDeveloper101 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 http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softwar...
true
0111bb11d918d2db6304db90d84dbcd52b65a70f
Rust
pola-rs/polars
/crates/polars-core/src/frame/hash_join/args.rs
UTF-8
5,870
2.8125
3
[ "MIT" ]
permissive
use super::*; pub(super) type JoinIds = Vec<IdxSize>; pub type LeftJoinIds = (ChunkJoinIds, ChunkJoinOptIds); pub type InnerJoinIds = (JoinIds, JoinIds); #[cfg(feature = "chunked_ids")] pub(super) type ChunkJoinIds = Either<Vec<IdxSize>, Vec<ChunkId>>; #[cfg(feature = "chunked_ids")] pub type ChunkJoinOptIds = Either...
true
044e8efeb0027d4c1baeeaf7eea3fa3426081780
Rust
taminhtienhai/UDPChatApp
/server/src/main.rs
UTF-8
699
2.984375
3
[]
no_license
use std::{net::UdpSocket, str}; fn main() { let ip_addr = "127.0.0.1:8888"; let remote_addr = "127.0.0.1:9999"; let host = UdpSocket::bind(ip_addr).unwrap(); host.set_broadcast(true).unwrap(); let mut buf = [0 as u8; 255]; match host.recv(&mut buf) { Ok(res) => { println!(...
true
51f3a77fb87ed303a667514e3e55fc16d091ee63
Rust
ajunlonglive/rustache
/src/errors.rs
UTF-8
751
2.546875
3
[ "MIT" ]
permissive
#![allow(missing_docs)] use rustc_serialize::json; use std::io; error_chain! { foreign_links { json::BuilderError, Json; } errors { StreamWriteError(err: io::Error, msg: String) { description("error writing to a stream") display("{}: {}", err, msg) } ...
true
10483de615717e866611cf8469163ae9953f195c
Rust
Luro02/tanoshi
/tanoshi-cli/src/test.rs
UTF-8
1,221
2.609375
3
[ "MIT" ]
permissive
use tanoshi_lib::prelude::Param; use tanoshi_vm::bus::ExtensionBus; pub async fn test( bus: ExtensionBus, selector: Option<String>, ) -> Result<(), Box<dyn std::error::Error>> { for detail in bus.list().await? { if let Some(selector) = selector.clone() { if detail.name != selector { ...
true
26467316a3ce8747152e4ba6e16e5eb3cd2528ed
Rust
aep000/ReactiveDB
/reactive_db/src/btree/node.rs
UTF-8
1,779
3.171875
3
[]
no_license
use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; #[derive(Debug, Serialize, Deserialize)] pub struct Node { pub entries: Vec<NodeEntry>, pub next_node: u32, pub leaf: bool, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct NodeEntry { pub...
true
d90b487e0c0c243b730ec268bda5ec448df81de6
Rust
Psykopear/calendars
/src/main.rs
UTF-8
3,336
2.78125
3
[ "MIT" ]
permissive
mod widgets; use druid::widget::{Button, Flex, WidgetExt}; use druid::{ theme, AppLauncher, Color, Data, Env, EventCtx, Lens, LocalizedString, Widget, WindowDesc, }; use std::sync::Arc; use chrono::{Date, Datelike, Duration, NaiveDate, Utc}; use widgets::Grid; #[derive(Clone, Data, Lens)] struct AppState { ...
true
94745becbea5ed28819fc3500203ff2ae02e3116
Rust
Frando/VIZIA
/src/tree/child_iter.rs
UTF-8
845
3.203125
3
[ "MIT" ]
permissive
use crate::{Tree, Entity, GenerationalId}; /// Iterator for iterating through the children of an entity. pub struct ChildIterator<'a> { pub tree: &'a Tree, pub current_forward: Option<Entity>, pub current_backward: Option<Entity>, } impl<'a> Iterator for ChildIterator<'a> { type Item = Entity; fn ...
true
17c0a057664ea3f3453dc8cad64976f638e7ee2e
Rust
PacktPublishing/Mastering-Rust
/Chapter02/library-example-1/src/lib.rs
UTF-8
187
2.953125
3
[ "MIT" ]
permissive
pub fn sum(a: i8, b: i8) -> i8 { return 0; } #[cfg(test)] mod tests { use super::sum; #[test] fn sum_one_and_one_equals_two() { assert_eq!(sum(1, 1), 2); } }
true
828e8b59697812624027782b098488ca8faeae61
Rust
clay53/konami_cipher
/src/lib.rs
UTF-8
11,306
3.203125
3
[]
no_license
use std::fmt::Write; #[derive(Debug)] pub enum KonamiParseError { Empty, TooManyUpDown(usize), UexpectedCharacter(usize, char) } pub fn konami_to_bytes(konami: String) -> Result<Vec<u8>, KonamiParseError> { let mut bytes = Vec::new(); #[derive(Debug)] enum ParseState { Up(u8), // 0: u...
true
5d22d4f0d3b9d83565727b3e08c0244abf8ce7e3
Rust
megamcloud/starcoin
/storage/src/batch/mod.rs
UTF-8
1,291
2.53125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::storage::{ColumnFamilyName, KeyCodec, ValueCodec, WriteOp}; use anyhow::Result; use std::collections::{BTreeMap, HashMap}; #[derive(Debug, Default, Clone)] pub struct WriteBatch { pub rows: HashMap<ColumnFamilyName, ...
true
bd0c1f8f4fae6ae89b776b36fac1135c9711b142
Rust
AQUIN0S/pong
/src/components/ball.rs
UTF-8
1,809
2.671875
3
[]
no_license
use amethyst::ecs::{ Component, DenseVecStorage, World, WorldExt, Builder }; use amethyst::renderer::{ SpriteSheet, SpriteRender }; use amethyst::assets::Handle; use amethyst::core::transform::Transform; use crate::pong::{ ARENA_WIDTH, ARENA_HEIGHT, BALL_VELOCITY_X, BALL_VELOCITY_Y, BALL_RADIUS }; pub const MAX_BALL_V...
true
259f1813bc5fcbcb730f3a69b77b57bacaa7959a
Rust
mkrasnitski/chip8
/rust/src/display.rs
UTF-8
2,998
3.21875
3
[]
no_license
use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::Canvas; use sdl2::video::Window; use crate::chip8::{CHIP8_HEIGHT, CHIP8_WIDTH}; const SCALE_FACTOR: usize = 10; const SCREEN_WIDTH: usize = CHIP8_WIDTH * SCALE_FACTOR; const SCREEN_HEIGHT: usize = CHIP...
true
3f13738381dc368ae4e0db8e1008923dff785932
Rust
PurpleBooth/fizz-buzz-rust
/src/main.rs
UTF-8
2,561
2.984375
3
[]
no_license
extern crate iron; extern crate router; use std::env; use iron::prelude::*; use iron::status; use router::Router; mod fizz_buzz; fn main() { let port: String = env::var("PORT").unwrap_or("8080".to_string()); let router = configure_router(); let listen_on = format!("0.0.0.0:{}", port); let _server =...
true
3aa32f96bd5c77d4b3766f964e21af2cbb2b64ef
Rust
davidoster/example-rust-api
/api/src/handlers.rs
UTF-8
6,678
2.8125
3
[]
no_license
use log::{trace, warn}; use models::pet::Pet; use tide::{Body, Request, Response, StatusCode}; use crate::error_response::ErrorResponse; use crate::state::State; pub(crate) async fn get_pet(req: Request<State>) -> tide::Result { let id: i32 = match req.param("id") { Ok(id) => id, Err(e) => { ...
true
ed5a657ea06608195331ccfbb4bad8b73c92897d
Rust
BobbyMcWho/ex-openssl
/native/exopenssl/src/crypto/x509.rs
UTF-8
2,330
2.640625
3
[ "MIT" ]
permissive
use openssl::x509::X509; use rustler::{Env, Term, NifResult, Encoder}; use rustler::resource::ResourceArc; use crate::errors::to_term as error_stack_to_term; use openssl::stack::Stack; use openssl::error::ErrorStack; use openssl::x509::store::X509Store; use openssl::x509::store::X509StoreBuilder; mod atoms { rustl...
true
c8d7401ea4a877a0cec801dc59af3cf0a556f390
Rust
GraphiteEditor/Graphite
/node-graph/gstd/src/cache.rs
UTF-8
1,330
2.71875
3
[ "MIT", "Apache-2.0", "ISC", "BSL-1.0", "BSD-2-Clause", "MPL-2.0", "Unicode-DFS-2016", "BSD-3-Clause", "CC0-1.0" ]
permissive
use parking_lot::RawRwLock; use std::{ any::Any, borrow::Borrow, cell::RefCell, collections::{hash_map::DefaultHasher, HashMap}, hash::{Hash, Hasher}, iter, iter::Sum, marker::PhantomData, }; use storage_map::{StorageMap, StorageMapGuard}; /// Caches the output of a given Node and acts as a proxy /// Automatic...
true
976f31d3adb919e888e5d0b421bed7d082b86707
Rust
TheEdward162/vcgencmd-rs
/src/lib.rs
UTF-8
4,218
3.21875
3
[]
no_license
//! Provides actual bindings and wrapper around VideoCore gencmd interface. //! //! The raw bindings are available in the [`ffi`](ffi) module. //! //! Currently implemented commands can be seen in [`gencmd::commands`](gencmd::commands) module. Note that //! since the gencmd interface is a simple textual protocol it can...
true
b4ada98a42f32101542ac736e4c32d5a0cb04cea
Rust
Tim-Zhang/rust-protobuf
/protobuf/src/reflect/dynamic/map.rs
UTF-8
6,817
2.875
3
[ "MIT" ]
permissive
use std::collections::hash_map; use std::collections::HashMap; use std::fmt; use std::hash::Hash; use crate::reflect::map::ReflectMap; use crate::reflect::map::ReflectMapIter; use crate::reflect::map::ReflectMapIterTrait; use crate::reflect::runtime_types::RuntimeTypeTrait; use crate::reflect::ProtobufValue; use crate...
true
0b82cc6405e7e052318eac0146b1d0046d5bdc22
Rust
MDoerner/AdventOfCode2020
/Rust/adventOfCode2020/src/day/day9.rs
UTF-8
5,500
3.140625
3
[]
no_license
use super::day1; pub struct Day9 {} impl super::Day for Day9{ type PuzzleInput = Vec<u32>; fn parse_input(&self, text: std::string::String) -> Self::PuzzleInput { text.lines() .map(|line| line.parse::<u32>()) .filter_map(Result::ok) .collect() } ...
true
32bb2a2f1faf77e8f2e275aa447e04f857039ef4
Rust
modrinth/minos-old
/src/utils/password_hashing.rs
UTF-8
781
2.65625
3
[ "Apache-2.0" ]
permissive
use crate::utils::error::WebsiteError; use crate::utils::error::WebsiteError::CryptoError; use sodiumoxide::crypto::pwhash::argon2id13; pub fn hash_password(password: String) -> Result<Vec<u8>, WebsiteError> { sodiumoxide::init().unwrap(); match argon2id13::pwhash( password.as_bytes(), argon2id...
true
f75ed9f1cddcc0556dba387429a27888b780c049
Rust
phodina/fgen
/src/interface.rs
UTF-8
3,148
2.6875
3
[]
no_license
use std::ffi::CStr; use libc; use std::path::Path; use std::result::Result::{Err, Ok}; pub use tera::Context; use generator::Generator; pub mod c_api { use super::*; #[no_mangle] pub extern "C" fn context_new() -> *mut Context { Box::into_raw(Box::new(Context::new())) } #[no_mangle] ...
true
a04c61149146d2eedb58a7bf6e4dfa03bac8a4fc
Rust
eagna-io/Eagna
/backend/app/src/routes/comments/post.rs
UTF-8
1,577
2.65625
3
[]
no_license
use crate::{ context::Context, filters::auth, res::{handler_fn, response, Error, Response}, }; use chrono::{DateTime, Utc}; use domain::{account::AccountId, comment::Comment, contest::ContestId}; use http::StatusCode; use infra::pg::{comment::CommentRepository, contest::ContestRepository}; use schemars::Jso...
true
38c25b2be9f8137face3f58127a63b14bf27bc13
Rust
CodeBreaker444/rust_basics-snippets-cheatsheet
/level1/src/data_structures.rs
UTF-8
1,861
3.640625
4
[]
no_license
use std::io; use std::io::Write; fn main(){ base_structure(); } //Structs are similar to tuples. struct user{ username: String, email: String, login_count: u64, active: bool, blocked: bool, } pub fn base_structure(){ let mut user1=user{ blocked: false, ...
true
c4120eb2c8802832e60c309d3e10d245e908bc0b
Rust
emgre/orbiter-rs
/orbiter/src/object.rs
UTF-8
6,420
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{oapic_VECTOR3, Vector3}; use crate::{Planet, Star, SurfaceBase, Vessel}; use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int}; use winapi::shared::minwindef::DWORD; #[doc(hidden)] pub enum _OBJHANDLE {} pub type OBJHANDLE = *mut _OBJHANDLE; /// Common methods for all objects pub trait ObjectTr...
true
4f191325ce3886760bd4c8b349286c6bd6031fd7
Rust
peerhenry/solid_uniforms
/src/gl_sender.rs
UTF-8
1,460
3.09375
3
[]
no_license
use std::marker::PhantomData; use gl; use gl::types::{GLint, GLfloat}; use traits::GlSendBehavior; use cgmath::{Matrix, Matrix3, Matrix4}; // -- OpenGL Send Behavior -- pub struct GlSender<T>{ pub handle: GLint, pub phantom: PhantomData<T> // marker to allow the struct to be generic } #[allow(non_camel_case_type...
true
cd7eefe0f37307d7a429f322bb3d3f3c63cebc8b
Rust
Flaise/steamworks-rs
/examples/workshop/src/main.rs
UTF-8
6,208
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::{path::Path, sync::mpsc::TryRecvError}; use steamworks::{Client, ClientManager, PublishedFileId, UGC}; fn create_item(ugc: &UGC<ClientManager>) { // creating a new workshop item // make sure you change the appid to the specified game ugc.create_item(480, steamworks::FileType::Community, |create_r...
true
ce12a44de62cb4331c3626c4c6fec371e6ee4e31
Rust
KremerMichael/sol-test
/src/processor.rs
UTF-8
2,094
2.625
3
[]
no_license
//! Program instruction processor use solana_program::{ //TODO }; pub struct Proccesor {} impl Processor { // init_account??? // init_multisig??? // revoke??? // set_authority??? // transfer // approve // close_account??? // toggle_freeze_account ??? //! Harvest ...
true
05ccd548b81d61553dab632ed3912267e8dc7dc9
Rust
ChristianLowe/ReverseCarlos
/src/board.rs
UTF-8
5,770
3.203125
3
[]
no_license
use std::fmt; use strum::IntoEnumIterator; use cell::Cell; use direction::{Direction, ShiftType}; pub struct Board { white_board: u64, black_board: u64, } pub enum CellState { White, Black, Empty, } #[derive(Clone, Copy, PartialEq)] pub enum Player { White, Black, } impl fmt::Display fo...
true
5b2824de42afaa86e445c4a38fc9940e8b78723c
Rust
neutronest/rustlib
/tests/lib.rs
UTF-8
1,797
2.84375
3
[ "MIT" ]
permissive
extern crate rustlib; extern crate rand; use rustlib::skiplist::{SkipNode, SkipList}; use rand::Rng; /* #[test] fn test_skipnode() { let k = String::from("apple"); let k1 = String::from("orange"); let k2 = String::from("banana"); let mut sn = SkipNode::new(k, 0.5, 10); let mut sn1 = Box::new(SkipN...
true
1bebc48cb3adf5876c22aac433611dae6e23a64f
Rust
crackofdusk/rusty
/rust/src/lib.rs
UTF-8
754
3.234375
3
[]
no_license
// Example code from this blog post about calling Rust from Ruby: // http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/ use std::num::pow; pub struct Point { x: int, y: int } struct Line { p1: Point, p2: Point } impl Line { pub fn length(&self) -> f64 { let xdiff = self.p1.x - ...
true
6c0207c219cf413e042b9d0454969e6d041e6778
Rust
Stannislav/Advent-of-Code
/2020/src/bin/01.rs
UTF-8
2,493
3.84375
4
[ "MIT" ]
permissive
use std::cmp::Ordering; use std::fs; /// Solve part 1. /// /// Find the two numbers that sum to 2020 and return their product. /// /// # Arguments /// * `numbers` - The problem input as a sorted vector. /// /// # Description /// Assuming that `numbers` is sorted it runs indices, `i` and `j`, /// one from the left and ...
true
0bb899cab53f028751424bffb666eb9f3d435c7b
Rust
xuorig/anicca
/src/diff/path_items.rs
UTF-8
6,615
2.765625
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use super::operations::OperationDiff; use super::DiffError; use crate::openapi::{Operation, PathItem, ReferenceOr}; use serde::Serialize; use std::collections::HashMap; pub type PathItemPair = (String, ReferenceOr<PathItem>); pub type OperationMethod = (String, Operation); #[derive(Debug, Default, Serialize)] pub st...
true
7a49d84c55aaa75e985063d155ce3736535e3471
Rust
Alastair-smith2/weather-cli
/src/file/write.rs
UTF-8
631
3
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use crate::result::Result; pub fn write_file<T: std::fmt::Display>(to_write: T) -> Result<()> { let mut file = File::create("weather.txt")?; file.write_all(to_write.to_string().as_bytes())?; Ok(()) } pub fn read_file() -> Result<()> { ...
true
62be2571e0190d9179d2cd3a4e96b8dbd039c819
Rust
endre90/micro_sp
/src/core/sp_value.rs
UTF-8
5,472
3.609375
4
[]
no_license
use ordered_float::OrderedFloat; use serde::{Deserialize, Serialize}; use std::fmt; use std::time::SystemTime; /// Represents a variable value of a specific type. #[derive(Debug, PartialEq, Clone, Hash, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub enum SPValue { Bool(bool), Float64(OrderedFloat<f64>), ...
true
f7a8a7ecdfb2204cf8237ed8b19dcfe31b12eb55
Rust
gelfand/etk
/etk-4byte/src/lib.rs
UTF-8
1,332
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
//! EVM Toolkit Function Selector Database. //! //! To roughly quote [4byte.directory](https://www.4byte.directory): //! //! > Function calls in the Ethereum Virtual Machine are specified by the first //! > four bytes of data sent with a transaction. These function selectors are //! > defined as the first four bytes of...
true
5682cb640e00b3d59e143feef29ca9f36a74db77
Rust
Skadic/archimedean-spiral
/src/rainbow.rs
UTF-8
978
3.578125
4
[]
no_license
pub struct RainbowIterator { x: f32 } impl RainbowIterator { pub fn new() -> RainbowIterator { RainbowIterator { x: 0.0, } } } impl Iterator for RainbowIterator { type Item = [f32; 4]; fn next(&mut self) -> Option<Self::Item> { use std::f32::consts; le...
true
34ea32edd28f22913fe3cd94cf9ce6601d15fa13
Rust
wbigger/RustTv
/src/gear.rs
UTF-8
563
3.09375
3
[]
no_license
use std::f64::consts::PI; pub struct Gear { pub pitch_circle_radius: f64, pub addendum: f64, pub teeth_num: i32 } impl Gear { pub fn addendum_circle_radius(&self) -> f64 { self.pitch_circle_radius + self.addendum } pub fn pitch(&self) -> f64 { 2.0 * PI * self.pitch_circle_radi...
true
244c7f02f36b5ec1e383b8118e05fad96f5cb982
Rust
jaynus/survival
/core/src/defs/action.rs
UTF-8
2,045
2.515625
3
[]
no_license
use crate::{ defs::{property::Property, Definition, Named}, fsm::{Condition, Event}, shrinkwraprs::Shrinkwrap, }; use survival_derive::NamedDefinition; #[derive( Shrinkwrap, Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, serde::Serialize, ...
true
28e69719f0379111f54136e67e54523f86984987
Rust
LucioFranco/tokio-bincode
/src/lib.rs
UTF-8
4,777
3.203125
3
[ "MIT" ]
permissive
//! Tokio codec for use with bincode //! //! This crate provides a `bincode` based codec that can be used with //! tokio's `Framed`, `FramedRead`, and `FramedWrite`. //! //! # Example //! //! ``` //! # use futures::{Stream, Sink}; //! # use tokio::io::{AsyncRead, AsyncWrite}; //! # use tokio_codec::Framed; //! # use se...
true
65dc7d6e5e7775523f5e659940d178455fc00077
Rust
glide1/exercism
/rust/word-count/src/lib.rs
UTF-8
403
3.265625
3
[]
no_license
use std::collections::HashMap; pub fn word_count(words: &str) -> HashMap<String, u32> { let mut counts : HashMap<String, u32> = HashMap::new(); let fixed_string : String = words.to_lowercase().chars().filter(|c| c.is_whitespace() || c.is_alphanumeric()).collect(); for word in fixed_string.split_whitespace(...
true
6ef308bd4014fe6da23e96480237871061103197
Rust
fLotte-meets-HWR-DB/msg-rpc
/src/server.rs
UTF-8
3,245
3
3
[ "Apache-2.0" ]
permissive
use std::net::{TcpListener, TcpStream}; use std::io::{Read, ErrorKind, Write}; use std::io; use byteorder::{BigEndian, ByteOrder}; use crate::message::Message; use std::sync::{Arc, Mutex}; use std::sync::mpsc::{Receiver, Sender, channel}; use crossbeam_utils::sync::WaitGroup; use std::mem; use scheduled_thread_pool::Sc...
true
a942e3d7269e3c0cd90bcf10fc89ad125b8360bb
Rust
veasnama/rsmixer
/src/ui/widgets/volume.rs
UTF-8
4,798
2.84375
3
[ "MIT" ]
permissive
use super::Widget; use crate::{ draw_at, repeat_string, ui::util::{get_style, Rect}, RSError, }; use std::{ cmp::{max, min}, io::Write, }; use crossterm::{cursor::MoveTo, execute}; #[derive(Copy, Clone, PartialEq, Debug)] pub enum VolumeWidgetBorder { Single, Upper, Lower, None, ...
true
9b0e0fa32d566911938c79133e57dd0a8e617210
Rust
SimonSapin/gregor
/src/time_zones.rs
UTF-8
10,829
3.5625
4
[]
no_license
use core::fmt; use super::{NaiveDateTime, DateTime, UnixTimestamp, Month, DayOfTheWeek}; use num::{div_floor, positive_rem}; pub trait TimeZone { fn from_timestamp(&self, t: UnixTimestamp) -> NaiveDateTime; fn to_timestamp(&self, d: &NaiveDateTime) -> Result<UnixTimestamp, LocalTimeConversionError>; } /// Whe...
true
49dd52f0579ab28ccca8a63d9a313d3d3d0b1d76
Rust
TuckerBMorgan/GoBoom
/examples/server.rs
UTF-8
5,813
2.6875
3
[]
no_license
mod server_lib; use GoBooM::*; use std::sync::mpsc::{channel, Sender, Receiver}; use std::net::{TcpListener, TcpStream}; use std::thread; use std::str; use std::io::prelude::*; use serde_json::{Value}; use server_lib::*; pub fn create_game_for_two_playaer(player_1: TcpStream, player_2: TcpStream) { println!("Ga...
true
8cf0718d57b9108ff5dea9fd40c290af78e362ec
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_81/src/solution1.rs
UTF-8
1,970
3.625
4
[ "MIT" ]
permissive
impl Solution { pub fn search(nums: Vec<i32>, target: i32) -> bool { let n = nums.len() as i32; if n == 0 { return false; } if n == 1 { return nums[0] == target; } let mut left: i32 = 0; let mut right: i32 = n - 1; while left <...
true
23b5fc1e2f3d22df3d9dcb91f53f67d5556662c7
Rust
emakryo/cmpro
/rs/src/kitamasa.rs
UTF-8
1,364
2.90625
3
[]
no_license
pub fn kitamasa<T>(a: &[T], c: &[T], n: usize) -> T where T: Clone + Copy + std::ops::Mul<Output=T> + std::ops::Add<Output=T> + From<usize> { let k = a.len(); assert_eq!(k, c.len()); fn rec<T>(c: &[T], n: usize) -> Vec<T> where T: Clone + Copy + std::ops::Mul<Output=T> + std::ops::Add<Output=T> + From...
true
aecd4f8ff27b51ed4dc8f4029d8fa9a1e4ad3391
Rust
mutetea/cs420-compiler
/l3/vm/rust/src/memory.rs
UTF-8
2,259
2.890625
3
[]
no_license
use crate::L3Value; use crate::{TAG_REGISTER_FRAME}; pub struct BaseRegisters { pub ib: usize, pub lb: usize, pub ob: usize, } pub struct Memory { content: Vec<L3Value>, free_ix: usize, } fn header_pack(tag: L3Value, size: L3Value) -> L3Value { debug_assert!(0 <= size && size <= 0xFF_FFFF); ...
true
b78ea189eacb9f46578709caff482eabe39fbda0
Rust
fx2y/setoff
/setoff-database/src/atomic_db.rs
UTF-8
328
2.6875
3
[]
no_license
/// An atomic database. Allows to batch a list of mutations, and guarantees to apply them to the database in an atomic manner. pub trait AtomicDb { type State; type Mutation; type Error; fn get_state(&self) -> &Self::State; fn mutate_db(&mut self, mutations: &[Self::Mutation]) -> Result<(), Self::E...
true
01f65cae1e2dcaa4b195dc050425884d60c26790
Rust
torbencarstens/event-manager-backend
/src/graphql/queries/location.rs
UTF-8
1,978
2.75
3
[]
no_license
use crate::database; use crate::database::Constraints; use crate::database::location::LocationQueryBuilder; use crate::graphql::GraphQLError; #[derive(Debug, GraphQLInputObject)] pub(crate) struct LocationQuery { pub(crate) id: Option<i32>, pub(crate) name: Option<String>, pub(crate) website: Option<String...
true
947acf703106d24bed12ed9d2d9b29c06b9a4046
Rust
rapidsockets/rust-sdk
/src/main.rs
UTF-8
3,986
2.78125
3
[]
no_license
extern crate json; extern crate ws; mod rapidsockets { use json; use ws::{connect, CloseCode}; fn noop(_: String) {} pub struct Config { gateway: String, api: String, key: String, } impl Config { pub fn init() -> Config { Config { ...
true
65432fb3baf90618b6e782d274c8ac12cd37e8a0
Rust
ViliamVadocz/Onitama-Alpha-Zero
/tensor/src/array_init.rs
UTF-8
206
2.53125
3
[]
no_license
pub(crate) fn array_init<T, F, const N: usize>(mut f: F) -> [T; N] where F: FnMut(usize) -> T, { let mut i = 0; [(); N].map(|()| { let elem = f(i); i += 1; elem }) }
true
66b28045b9c5d5ab6ddf52018cd513aea40400d0
Rust
rerpha/anagrams
/src/main.rs
UTF-8
2,424
3.5
4
[]
no_license
#[macro_use] extern crate clap; use clap::App; use itertools::Itertools; fn generate_anagrams(word: &str) -> Vec<String> { let mut anagrams = Vec::new(); let vec = word.chars().collect::<Vec<char>>(); for perm in vec.iter().permutations(vec.len()).unique() { if perm.len() > 0{ anagrams....
true
c8ba85510217975a9cc837975940f10b0e65a36b
Rust
casey/intermodal
/src/files.rs
UTF-8
692
2.921875
3
[ "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
use crate::common::*; #[derive(Debug)] pub(crate) struct Files { root: PathBuf, total_size: Bytes, contents: Option<Vec<FilePath>>, } impl Files { pub(crate) fn file(root: PathBuf, total_size: Bytes) -> Files { Files { contents: None, root, total_size, } } pub(crate) fn dir(root...
true
84bece08cbc3fb74b356a50592b7a6dfd640d089
Rust
vorner/signal-hook
/signal-hook-async-std/tests/async_std.rs
UTF-8
1,343
2.734375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use async_std::stream::StreamExt; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use signal_hook::consts::SIGUSR1; use signal_hook::low_level::raise; use signal_hook_async_std::Signals; use serial_test::serial; #[async_std::test] #[serial] async fn next_returns_recieved_...
true
f9d48221aa16489a71ad51bc7d00fbce0a011f2b
Rust
breckinloggins/rusticom
/nesfile.rs
UTF-8
4,261
2.90625
3
[]
no_license
// Copyright 2014 Breckin Loggins // // Reads the iNES file format use std::str; use std::path::Path; use std::io::{File, fs}; // iNES ROM format: http://wiki.nesdev.com/w/index.php/INES pub struct Header { magic: [u8, ..4], // Should be "NES" + 0x1A prg_size: u8, // PRG ROM siz...
true
21666a3f99901fcbf85439a28ad2f5d3a6f16cb3
Rust
sbstp/supermon
/src/utils.rs
UTF-8
554
2.59375
3
[]
no_license
use std::fmt; use nix::unistd; #[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] pub struct Pid(pub i64); impl Pid { pub fn to_nix(&self) -> unistd::Pid { unistd::Pid::from_raw(self.0 as i32) } } impl From<u32> for Pid { fn from(pid: u32) -> Pid { Pid(pid as i64) } ...
true
334fed5993161c3ad0985a93650d9b9fd1eca306
Rust
den-taku/Notes
/file_input/src/main.rs
UTF-8
466
2.6875
3
[]
no_license
use std::fs::File; use std::io::copy; fn main() { let mut file_txt = File::open("text.txt").expect("txt error"); let mut file_asm = File::open("text.asm").expect("asm error"); let mut vec_txt = Vec::new(); let mut vec_asm = Vec::new(); let _ = copy(&mut file_txt, &mut vec_txt); let _ = copy(&...
true
8bc6cf5c86d16cd87e020663cab970c97e6df87a
Rust
ryanpbrewster/rust-project-euler
/src/util/math/pythag.rs
UTF-8
1,868
3.75
4
[]
no_license
#[derive(PartialEq, PartialOrd, Ord, Debug, Eq, Clone, Copy)] pub struct Triple { pub a: u32, pub b: u32, pub c: u32, } impl Triple { pub fn root() -> Triple { Triple { a: 3, b: 4, c: 5 } } pub fn new(a: u32, b: u32, c: u32) -> Triple { assert!(a < b && b < c && a * a + b * b ==...
true
7f1739571801e624d8d1a6df9dc9c05c3649c26a
Rust
vigdail/raytracer
/src/entity/mod.rs
UTF-8
350
2.640625
3
[ "MIT" ]
permissive
use crate::{hit::Hittable, ray::Ray}; use self::sphere::Sphere; pub mod sphere; pub enum Entity { Sphere(Sphere), } impl Hittable for Entity { fn hit(&self, ray: &Ray, t_min: f32, t_max: f32) -> Option<crate::hit::HitRecord> { match *self { Entity::Sphere(ref inner) => inner.hit(ray, t_m...
true
9c09f989a3d5d58cde7ac637885275cba0298ca4
Rust
ajunlonglive/quick_sort
/src/bin/main.rs
UTF-8
1,129
3.109375
3
[]
no_license
extern crate may; extern crate num_cpus; extern crate quick_sort; extern crate rand; use quick_sort::*; use rand::{distributions::Standard, Rng}; use std::time; fn default_vec(n: usize) -> Vec<u32> { rand::thread_rng().sample_iter(Standard).take(n).collect() } fn is_sorted<T: Send + Ord>(v: &[T]) -> bool { (...
true
91c22e10bf0e6e9f1a74ee628d440ca307b4adda
Rust
Hakuyume/rust-cuda
/cuda/src/memory/tests/memcpy.rs
UTF-8
836
2.796875
3
[]
no_license
extern crate rand; use super::Array; use super::super::memcpy; use self::rand::Rng; #[test] fn memcpy_random() { let src: Vec<_> = { let mut rng = rand::thread_rng(); (0..16).map(|_| rng.gen()).collect() }; let mut dev = Array::new(src.len()).unwrap(); memcpy(&mut dev, &src).unwrap()...
true
85e830321142258728d8a2947000f96c8b5ccf08
Rust
ranfdev/mdns
/src/io.rs
UTF-8
1,001
2.578125
3
[ "MIT" ]
permissive
use crate::{Error, mDNS}; use std::time::Duration; use mio; pub struct Io { pub poll: mio::Poll, pub events: mio::Events, token_accumulator: usize, } impl Io { pub fn new() -> Result<Self, Error> { let poll = mio::Poll::new()?; let events = mio::Events::with_capacity(1024); O...
true
82945836022782b80e05f57867e1bf1b3fe8e3a0
Rust
aochagavia/rocket
/src/controllers/input.rs
UTF-8
1,280
3.15625
3
[ "MIT" ]
permissive
use ggez::event::{KeyCode, KeyMods}; #[derive(Default)] pub struct InputController { actions: Actions, } /// Active actions (toggled by user input) #[derive(Default)] pub struct Actions { pub rotate_left: bool, pub rotate_right: bool, pub boost: bool, pub shoot: bool, } impl InputController { ...
true
917dbb54ae1b671d66bf112919c7cec54b3a0dc3
Rust
icefoxen/nanowasm
/src/interpreter.rs
UTF-8
81,482
3.296875
3
[ "MIT", "Apache-2.0" ]
permissive
//! The actual run-time interpreter. use std; use std::collections::HashMap; use byteorder; use byteorder::ByteOrder; use parity_wasm::elements; use types::*; use util::*; use loader::*; /// A label pointing to a particular block: just an instruction index. /// The label index is implicit in the labels stack; label...
true
5e5535d3a5ef7b82b68574c0fa46bad53e1ad74b
Rust
Mr-Quiz/Oxide
/oxide_widgets/ox_tokens.rs
UTF-8
870
2.96875
3
[ "MIT" ]
permissive
pub enum OxWidgetType { Component, Template, Button, Layout, LayoutItem, Box, Menu, Input, Image, Attribute, } impl OxWidgetType { pub fn parsing_value(&self) -> &str { match *self { OxWidgetType::Component => "<ox:component", _ => "test" } } } pub enum OxTokens { BaseTag...
true
ce9c70fd96a86f189928aa0f030903f0e78d0462
Rust
elbow-jason/open_cl_elixir
/native/open_cl_native/src/ex/error_ex.rs
UTF-8
2,085
2.71875
3
[]
no_license
use opencl_core::Error as OpenCLError; use opencl_core::ll::StatusCodeError; use rustler::Error as RustlerError; use rustler::{Encoder, Env, Term, NifStruct, NifUnitEnum}; use crate::ex::buffer_ex::BufferError; use crate::number::NumberTypeError; pub type OutputEx<T> = Result<T, ErrorEx>; /// An error for the OpenC...
true
b67876c2b69702744fa90787e057328c0bb0fbbe
Rust
arjandepooter/hack-assembler
/src/symbols.rs
UTF-8
2,771
3
3
[]
no_license
use crate::types::*; use std::collections::HashMap; pub type SymbolTable = HashMap<String, u16>; const SYMBOLS: [(&str, u16); 23] = [ ("SP", 0x0000), ("LCL", 0x0001), ("ARG", 0x0002), ("THIS", 0x0003), ("THAT", 0x0004), ("R0", 0x0000), ("R1", 0x0001), ("R2", 0x0002), ("R3", 0x0003)...
true
e7c97a817447bf51b0d7f42fb19e05caf31903a9
Rust
ellyish/rust-www
/_includes/pt-BR/example.rs
UTF-8
615
3.984375
4
[ "Apache-2.0", "MIT" ]
permissive
// Esse código é editável e executável! fn main() { // Uma calculadora simples de inteiros: // `+` ou `-` significa somar ou subtrair 1 // `*` ou `/` significa multiplicar ou dividir por 2 let programa = "+ + * - /"; let mut acumulador = 0; for simbolo in programa.chars() { match simbo...
true
5dfb6930d20004cce3a29b954434ef38e6b595d9
Rust
ben-han-cn/doodle
/language/rust/third_party_libs/gotham/service.rs
UTF-8
3,246
2.671875
3
[]
no_license
pub(crate) struct GothamService<T> where T: NewHandler + 'static, { handler: Arc<T>, } impl<T> GothamService<T> where T: NewHandler + 'static, { pub(crate) fn new(handler: T) -> GothamService<T> { GothamService { handler: Arc::new(handler), } } pub(crate) fn connect...
true
9854a7603e043b6e387302a944e2981aa851bc48
Rust
silan-liu/tiny-web-render-engine
/src/css.rs
UTF-8
6,398
3.234375
3
[]
no_license
use crate::source; #[derive(Debug)] pub struct StyleSheet { pub rules: Vec<Rule>, } #[derive(Debug)] pub struct Rule { pub selectors: Vec<Selector>, pub declarations: Vec<Declaration>, } #[derive(Debug)] pub enum Selector { Simple(SimpleSelector), } #[derive(Debug)] pub struct SimpleSelector { pub tag_nam...
true
bbbb4cb34e5043bfd46ca7431781ddcd262651f0
Rust
tz70s/rust-prac
/io_12/src/lib.rs
UTF-8
737
3.484375
3
[]
no_license
use std::env; // use std::error::Error; // parse args pub fn parse_args() -> Result<Config, &'static str> { let args: Vec<String> = env::args().collect(); if args.len() < 3 { return Err("not enough arguments"); } Ok(Config::new(&args)) } #[derive(Debug)] pub struct Config { pub content: St...
true
3134bcae973150b683ecd455aab47541eb78adb1
Rust
Canop/broot
/src/verb/verb_description.rs
UTF-8
422
3.171875
3
[ "MIT" ]
permissive
/// how a verb is described in the help screen #[derive(Debug, Clone)] pub struct VerbDescription { pub code: bool, pub content: String, } impl VerbDescription { pub fn from_code(content: String) -> Self { Self { code: true, content, } } pub fn from_text(cont...
true
c6d528cbfb4eba4abe1dd5a6ce8ddd7ce9001ab5
Rust
declanvk/scalable-concurrent-containers
/src/ebr/atomic_arc.rs
UTF-8
16,554
3.375
3
[ "Apache-2.0" ]
permissive
use super::underlying::Underlying; use super::{Arc, Barrier, Ptr, Tag}; use std::mem::forget; use std::ptr; use std::ptr::NonNull; use std::sync::atomic::AtomicPtr; use std::sync::atomic::Ordering::{self, Relaxed}; /// [`AtomicArc`] owns the underlying instance, and allows users to perform atomic operations /// on th...
true
cac1c2f1c22eb83714076987b2630b7014984c35
Rust
LeSeulArtichaut/twilight
/http/src/request/guild/role/update_role.rs
UTF-8
3,073
2.859375
3
[ "ISC" ]
permissive
use crate::{ client::Client, error::Error, request::{self, AuditLogReason, AuditLogReasonError, NullableField, Pending, Request}, routing::Route, }; use serde::Serialize; use twilight_model::{ guild::{Permissions, Role}, id::{GuildId, RoleId}, }; #[derive(Default, Serialize)] struct UpdateRoleF...
true
3a4dcbf912df96e320949167e6989f59461803b8
Rust
renatolond/advent_of_code
/2019/day_10_p2.rs
UTF-8
5,204
2.828125
3
[]
no_license
use std::process; use std::io; use std::io::prelude::*; use std::cmp::Ordering; const MAX_SIDE : usize = 1000; static mut ASTEROID_FIELD : [[usize; MAX_SIDE]; MAX_SIDE] = [[MAX_SIDE+1; MAX_SIDE]; MAX_SIDE]; static mut ASTEROID_POSITIONS : Vec<(usize, usize)> = Vec::new(); fn decomposed_distance(asteroid : (usize, us...
true
aa86c7542f4ae3251c9cdf0fed935a9bd2f9764a
Rust
aktoro-rs/aktoro
/examples/net/src/server.rs
UTF-8
2,169
2.6875
3
[ "MIT" ]
permissive
use aktoro::prelude::*; use aktoro::raw; use futures_util::AsyncReadExt; use futures_util::StreamExt; use crate::agent::Agent; struct Connection<S: raw::TcpServer>(S::Stream); struct Died; pub(crate) struct Server<S: raw::TcpServer> { pub(crate) tcp: Option<S>, pub(crate) cancellable: Option<Cancellable<Tcp...
true
b71be423e66611185f947fe6ede3fd384a63d8db
Rust
mardiros/rustaman
/src/ui/menu_item.rs
UTF-8
5,358
2.703125
3
[ "BSD-3-Clause" ]
permissive
use gdk; use gdk::keys::constants; use gtk::prelude::*; use gtk::{self, Orientation}; use relm::{connect, Relm, Update, Widget}; use super::super::models::Request; pub struct Model { request: Request, } impl Model { pub fn id(&self) -> usize { self.request.id() } pub fn name(&self) -> &str {...
true
9d3c49e54d48acbc56e50754995544710df7bf77
Rust
jonas-schievink/zathura-plugin
/src/page.rs
UTF-8
3,262
3.15625
3
[ "0BSD" ]
permissive
use { crate::{sys, DocumentRef}, std::marker::PhantomData, }; /// Reference to a page in a document. /// /// This does not expose the `get/set_visibility` functions because they return /// wildly inconsistent data between runs and even within the same Zathura /// instance. Zathura only calls the render callbac...
true
d9b46ea1d42f3366572937130407664e3fb3a35e
Rust
calmofthestorm/routerbolt
/routerbolt/tests/loop_test.rs
UTF-8
11,348
2.859375
3
[ "Apache-2.0" ]
permissive
use std::rc::Rc; use routerbolt::*; use test_util::*; enum LoopType { While, DoWhile, Infinite, } /// A test that can be done for all three loop types, which also exercises break /// (including nested break). fn test_common_loop_fixture(cell: bool, loop_type: LoopType) { let inner_body = "op add tmp ...
true
7a6f1d7591896dc159b5f1e0352c73861d5772e9
Rust
rutrum/ccase
/src/lib.rs
UTF-8
1,466
2.6875
3
[ "MIT" ]
permissive
mod app; mod case_extension; pub use app::build as build_app; pub use case_extension::*; use clap::error::{Error, ErrorKind}; use convert_case::{Case, Casing, Pattern}; fn pattern_value_parser(s: &str) -> Result<Pattern, Error> { let pattern_str = s.to_case(Case::Flat); for pattern in all_patterns() { ...
true
b7c551fd1212aabcba38e85d447bfdf6914242ac
Rust
HansTrashy/trashy_bot
/src/models/tag.rs
UTF-8
1,098
2.875
3
[ "MIT" ]
permissive
use futures::stream::TryStreamExt; use sqlx::postgres::PgPool; pub type DbError = sqlx::Error; #[derive(sqlx::FromRow, Debug)] pub struct Tag { pub id: i64, pub fav_id: i64, pub label: String, } impl Tag { pub async fn create(pool: &PgPool, fav_id: i64, label: &str) -> Result<Self, DbError> { ...
true
41ec33ebfac979c997ffbc706755577632ae7756
Rust
mluluz/lighthouse
/beacon_node/network/src/sync/simple_sync.rs
UTF-8
4,124
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::beacon_chain::BeaconChain; use eth2_libp2p::rpc::HelloMessage; use eth2_libp2p::PeerId; use slog::{debug, o}; use std::collections::HashMap; use std::sync::Arc; use types::{Epoch, Hash256, Slot}; /// The number of slots that we can import blocks ahead of us, before going into full Sync mode. const SLOT_IMPO...
true