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
0e0b9a57afbbfeb579f67a21c0a27025340a73a6
Rust
rainliu/leetcode
/src/398RandomPickIndex/398RandomPickIndex.rs
UTF-8
895
3.703125
4
[]
no_license
use rand::{thread_rng, Rng}; struct Solution { nums: Vec<i32>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl Solution { fn new(nums: Vec<i32>) -> Self { Solution { nums, } } ...
true
f047239048b86ff576d37b8aa98f00e2d8f99e67
Rust
whichxjy/wdr
/wdr/src/process.rs
UTF-8
4,243
2.78125
3
[]
no_license
use crossbeam::channel::{Receiver, Sender}; use std::fs::OpenOptions; use std::io::Write; use std::os::unix::fs::OpenOptionsExt; use std::path::Path; use std::process::{Child, Command}; use std::str; use std::sync::RwLock; use std::thread; use url::Url; use wdrlib::config::ProcessConfig; use wdrlib::info::{ProcessInfo,...
true
4cdfe64c6ecbfe4901a6e5c00ce563c97ac0efa5
Rust
SINHASantos/tonic
/tonic-types/src/richer_error/std_messages/bad_request.rs
UTF-8
6,424
2.921875
3
[ "MIT" ]
permissive
use prost::{DecodeError, Message}; use prost_types::Any; use crate::richer_error::FromAnyRef; use super::super::{pb, FromAny, IntoAny}; /// Used at the `field_violations` field of the [`BadRequest`] struct. /// Describes a single bad request field. #[derive(Clone, Debug)] pub struct FieldViolation { /// Path lea...
true
c04e60e18ebc6279428e2467904b0b43b228cb2f
Rust
drupalio/nakama-rs
/src/async_client.rs
UTF-8
3,814
2.734375
3
[ "Apache-2.0" ]
permissive
use super::api; use quad_net::http_request::{HttpError, Method, Request, RequestBuilder}; #[derive(Debug)] pub enum Error { IOError(std::io::Error), JsonError(nanoserde::DeJsonErr), HttpError(HttpError), } impl From<std::io::Error> for Error { fn from(error: std::io::Error) -> Error { Error::I...
true
e137deb52fec5b9bd45ba3c7cd67e6875c5f9d7b
Rust
cheme/wasm-sodium
/src/lib.rs
UTF-8
2,479
2.6875
3
[]
no_license
// reexport sodiumoxide #![feature(proc_macro, wasm_custom_section, wasm_import_module)] #![feature(use_extern_macros)] pub extern crate sodiumoxide; extern crate wasm_bindgen; extern crate libc_stub; // see comments on this crate for what this is extern crate openssl; use openssl::sha; fn hashopenssl() { let ...
true
097852406bc67ea345c55c3209c57ed98dde4db2
Rust
Byron/ruby-rust-examples
/points-and-lines/points.rs
UTF-8
875
3.640625
4
[]
no_license
use std::mem; pub struct Point { x: i32, y: i32 } impl Point { pub fn distance_to(&self, p: &Point) -> f64 { let xdiff = self.x - p.x; let ydiff = self.y - p.y; ((xdiff.pow(2) + ydiff.pow(2)) as f64).sqrt() } } impl Drop for Point { fn drop(&mut self) { use std::io::{Write, stderr}; ...
true
c197d4fcb2aaa2fb918f5a639c309c4d0480c132
Rust
miroslavkrysl/mvm
/src/vm/exec/vm.rs
UTF-8
5,015
2.828125
3
[]
no_license
use std::collections::HashMap; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; use crate::vm::class::class::Class; use crate::vm::class::descriptor::{ParamsDesc, ReturnDesc}; use crate::vm::class::instance::{Instance, InstanceId}; use crate::vm::class::name::{ClassName, MethodName...
true
90009491610af72fffd097fe0f0c85a8dddebcf7
Rust
zzliujianbo/dgmrcp
/src/config.rs
UTF-8
6,197
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Serde support for APR tables. use crate::ffi; use serde::{ de::{DeserializeSeed, SeqAccess, Visitor}, Deserialize, Deserializer, }; use std::{ ffi::{CStr, CString}, fmt, }; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("internal")] Internal, #[error("not supported")] ...
true
cb7eb9121b5c73d1859c51c471292c5f4c294db5
Rust
TakaakiFuruse/jump-kun
/src/enums.rs
UTF-8
476
2.890625
3
[]
no_license
use jump_kun_macros::order; use serde::{Deserialize, Serialize}; #[derive(PartialEq, Debug, Serialize, Deserialize, Clone, order, PartialOrd)] pub enum DirType { CurrentDir, ParentDir, ChildDir, VisitedDir, NotSure, Invalid, } #[cfg(test)] mod tests_for_dirtype { use super::*; #[test]...
true
02076b79c6f54e1ce0e89ece437ee0ff93653f5f
Rust
guonaihong/rust-example
/tcp-protobuf-and-server/src/server.rs
UTF-8
1,724
2.671875
3
[]
no_license
use protobuf::Message; use std::io; use std::net::{TcpListener, TcpStream}; use structopt::StructOpt; use tcp_protobuf_and_server::protos::small_model::*; use tcp_protobuf_and_server::utils::*; #[derive(StructOpt, Debug)] struct Server { /// server address #[structopt(short, long)] server_addr: String, } ...
true
3372bda6af8577727cfb7f90b7635cadaa487449
Rust
yingliufengpeng/rust_language
/ch98_little_book_of_macro/src/ch4_7_tt_bundling.rs
UTF-8
2,344
3.3125
3
[]
no_license
macro_rules! log { ($e:tt) => { println!("item is {:?}", "i"); }; } macro_rules! call_a_or_b_tail { ((a: $a:expr, b: $b:expr), call a: $($tail:tt)*) => {{ $a(stringify!($($tail)*)) }}; ((a: $a:expr, b: $b:expr), call b: $($tail:tt)*) => {{ $b(stringify!($($tail)*)) }}; ($ab:tt...
true
91896ae4adaca0990c128111f1d2aa465ca8955f
Rust
jonathanrlouie/ld45
/src/tile.rs
UTF-8
588
2.671875
3
[]
no_license
use amethyst::{ core::math::Point3, ecs::{World, WorldExt}, tiles::Tile }; use crate::tile_map::TileMap; #[derive(Default, Clone)] pub struct TerrainTile; impl Tile for TerrainTile { fn sprite(&self, point: Point3<u32>, world: &World) -> Option<usize> { let tile_map = world.read_resource::<Tile...
true
d2e28d8bc5cb5902be917b5ac48996f50b264122
Rust
nikhilkalige/stm32f411-bsp
/src/serial.rs
UTF-8
6,680
2.65625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use core::any::{Any, TypeId}; use core::marker::Unsize; use core::ops::Deref; use core::ptr; use cast::u16; use hal; use hal::serial::Write; use nb; use time::U32Ext; // use static_ref::Ref; use stm32f411::{usart1, USART1, USART2, USART6}; /// Specialized `Result` type pub type Result<T> = ::core::result::Result<T, ...
true
7fc6c04ed931bf80510e674e68caef38b86cd109
Rust
burtonageo/average
/src/main.rs
UTF-8
2,807
3.484375
3
[]
no_license
/* * Written by George Burton on the 15th Jan, 2014 * * average - a warmup exercise for PS1 from CSC4414 from University of Virginia * file: main.rs * * This is free and unencumbered software released into the public domain. */ use std::env::args; mod mean; /// Simple CLI app to calculate the mean of numerica...
true
d2533671b3b26b856c88810a7941331b2a41024d
Rust
withoutboats/notty-encoding
/src/client.rs
UTF-8
304
2.71875
3
[]
no_license
use std::io::{self, Write}; use cmds::EscCode; pub trait Client { fn write(&mut self, &EscCode) -> io::Result<()>; } pub struct StdioClient; impl Client for StdioClient { fn write(&mut self, code: &EscCode) -> io::Result<()> { io::stdout().write_all(code.encode().as_bytes()) } }
true
7d52211956900a40faf41de2be2825f5ab3ce1ce
Rust
tommyshem/learn-to-code
/learn-rustlang/coding-exercises/rust-examples/strings/src/slice.rs
UTF-8
609
3.421875
3
[]
no_license
#![allow(unused_variables, dead_code)] pub fn slice_example(arg: &str) { let s = String::from("test sentence"); // First to bytes as a slice using range .. let slice1 = &s[0..2]; println!("{:?}", slice1); let slice2 = &s[..2]; // same as slice1 println!("{:?}", slice2); // from set point t...
true
1688220f4a76acf440d28222e1dbd67827a0318a
Rust
sbuzonas/hhvm
/hphp/hack/src/hackc/ir/ir_core/string_intern.rs
UTF-8
1,755
3.015625
3
[ "PHP-3.01", "Zend-2.0", "MIT" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use std::borrow::Cow; use bstr::BStr; use hash::IndexSet; use newtype::newtype_int; // Improvement list: // // - In debug mode have Un...
true
8af03fdcfb7b2752940bb3d1148741e3ae91c68a
Rust
Montessquio/Rust-OS
/src/interrupts/serialkbd/layouts/uk105.rs
UTF-8
2,127
3.125
3
[ "MIT" ]
permissive
//! A standard United Kingdom 102-key (or 105-key including Windows keys) keyboard. //! Has a 2-row high Enter key, with Backslash next to the left shift. use super::super::{DecodedKey, HandleControl, KeyCode, KeyboardLayout, Modifiers}; pub use super::us104::Us104Key; pub struct Uk105Key; impl KeyboardLayout for U...
true
654694d558eafe006b394c86fe73bfcf0604ebe8
Rust
nordsoyv/rust_win32
/game-core/src/entities/enemies.rs
UTF-8
2,080
3.125
3
[]
no_license
use entities::{player::Player, BoundingBox, Collider, Color, Drawable, Position}; use math::{pulse_value, vector::Vector2d}; pub enum EnemyType { Normal, } pub struct Enemy { enemy_type: EnemyType, pos: Vector2d, width: f32, height: f32, color: Color, life_time: f32, } impl Enemy { pu...
true
ca0528ede4f9b1d2050776973f9a5a13d750c7d6
Rust
pzmarzly/IRust
/src/history.rs
UTF-8
1,178
3.328125
3
[ "MIT" ]
permissive
pub struct History { pub buffer_vec: Vec<String>, cursor: usize, empty: String, } impl Default for History { fn default() -> Self { Self { buffer_vec: Vec::new(), cursor: 0, empty: String::new(), } } } impl History { pub fn down(&mut self) -> S...
true
fac4e8fa17098721888b5d6b67360a857abe2594
Rust
dylanalvarez/tp3_concurrentes
/src/blockchain_node.rs
UTF-8
25,419
2.53125
3
[]
no_license
use std::collections::HashMap; use std::net::UdpSocket; use std::sync::{Arc, Condvar, Mutex}; use std::time::Duration; use std::{thread, usize}; use crate::acquire_message::AcquireMessage; use crate::add_grade_message::AddGradeMessage; use crate::blockchain::Blockchain; use crate::blockchain_message::BlockchainMessage...
true
f28097f9dd899459343665bb994a0b1fb38684fe
Rust
ccojocar/rusty-hog
/src/bin/berkshire_hog_lambda.rs
UTF-8
5,700
2.828125
3
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
//! An S3 secret scanner designed to be run as a Lambda function //! //! Berkshire Hog is currently designed to be used as a Lambda function. This is the basic data flow: //!```text //! ┌───────────┐ ┌───────┐ ┌────────────────┐ ┌────────────┐ //! │ S3 bucket │ ┌────────┐ │ │ │ ...
true
51eb2cfd96ba8a8e40ab403f1c7851597d134cd4
Rust
mcountryman/chip8
/src/ui/keys.rs
UTF-8
2,421
3.328125
3
[]
no_license
//! Terminal events. use crossterm::event::{self, Event, KeyEvent}; use std::{ ops::Deref, sync::mpsc, thread, time::{Duration, Instant}, }; /// A terminal events iterator. pub struct UiKeys { rx: mpsc::Receiver<KeyEventWithState>, _tx: mpsc::Sender<KeyEventWithState>, } #[derive(Debug, Clone, Copy)] pub...
true
ed368c059b59314962b16a1e03c11dd21603fad5
Rust
kuwana-kb/ddd-in-rust
/chapter09_factory/src/infrastructure/datastore/rdb_context.rs
UTF-8
1,474
2.765625
3
[]
no_license
use std::fmt; use anyhow::Result; use common::MyError; use crate::{ domain::{Name, User, UserFactory, UserRepository}, infrastructure::PgPool, }; #[derive(Clone)] pub struct RDBContext { pool: PgPool, } impl Default for RDBContext { fn default() -> Self { let pool = PgPool::new(); Se...
true
2d64e4793fd31db5eaacfe69051b572067b2f59b
Rust
sandialabs/Polymers
/src/physics/single_chain/ideal/thermodynamics/isotensional/test.rs
UTF-8
42,308
2.59375
3
[ "BSD-3-Clause" ]
permissive
#![cfg(test)] use super::*; use crate::physics::single_chain::test::Parameters; mod base { use super::*; use rand::Rng; #[test] fn init() { let parameters = Parameters::default(); let _ = Ideal::init(parameters.number_of_links_minimum, parameters.link_length_reference, par...
true
131826c7b6ccfb9028f913942de62bd352f92ab2
Rust
barollet/baba_solver
/src/rules.rs
UTF-8
1,293
3.296875
3
[]
no_license
//! A rule manager, the rules are manually updated by the level interface //! This a 2D boolean table indexed by entity and text use std::ops::{Index, IndexMut}; use crate::square::*; type TextLine = [bool; TEXTS_NUMBER]; #[derive(Clone, Debug)] pub struct RuleManager([TextLine; Entity::VARIANT_COUNT]); impl Defau...
true
e8bdfc2316e45487a5a83f09a9e4f78fffc60238
Rust
tsgates/exa
/src/output/render/times.rs
UTF-8
1,541
3
3
[ "MIT" ]
permissive
use datetime::TimeZone; use ansi_term::Style; use ansi_term::Colour::{Red, Cyan, Yellow, Green, Purple, Blue}; use crate::output::cell::TextCell; use crate::output::time::TimeFormat; pub trait Render { fn render(self, style: Style, tz: &Option<TimeZone>, format: &T...
true
8aef52fd0548ca04effbb9b8dd1db3d6984dc214
Rust
JiriHartikka/rust-chess-engine
/src/search/test_utils.rs
UTF-8
561
2.640625
3
[ "MIT" ]
permissive
use crate::model::game_state::GameState; use crate::model::move_generator::MoveGenerator; use crate::uci::uci_utils::parse_move; pub fn apply_position<I>(moves: I, game_state: &mut GameState, move_generator: &MoveGenerator) where I: IntoIterator<Item = String>, { let parsed_moves = moves .into_iter() ...
true
8edbdca19bfd02eee8f7416e5a182f94e8352d44
Rust
backciro/Rust
/src/sorting/merge_sort.rs
UTF-8
1,251
3.515625
4
[]
no_license
/// Sort a mutable slice using merge sort. /// /// Merge sort is an in-place O(n log n) sorting algorithm on a every case. \ /// It is based on a max subsequence of slices based on a central pivot, full sequence is splitten within n subsequence /// and every sequence is being ordered alone, then merged all together. //...
true
60cf7b21f3669afe30a1f907f38715984e5d6c4d
Rust
toyseed/WebServer_2
/src/server/server.rs
UTF-8
2,476
2.9375
3
[ "MIT" ]
permissive
use std::io::Error; use std::net::TcpListener; use std::sync::Arc; use crate::route::route::Route; use crate::route::RouterBuilder; use crate::server::ServerConfig; use crate::worker::HttpTask; use crate::worker::worker_manager::WorkerManager; pub struct Server { server_config: ServerConfig, worker_manager: W...
true
b56daa5044569951d2053b92ad06828aaac3da39
Rust
Garvys/rustfst
/rustfst/src/algorithms/fst_convert.rs
UTF-8
2,177
2.84375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::fst_traits::{AllocableFst, ExpandedFst, Fst, MutableFst}; use crate::semirings::Semiring; use crate::Trs; /// Generic method to convert an Fst into any other types implementing the MutableFst trait. pub fn fst_convert_from_ref<W, F1, F2>(ifst: &F1) -> F2 where W: Semiring, F1: Fst<W>, F2: Mutabl...
true
cfdb0f2ad0ea76fbfd8c0183bd5ffa8ec8b267f0
Rust
gevious/monopoly
/backend/src/square.rs
UTF-8
3,406
3.390625
3
[ "MIT" ]
permissive
use std::cell::RefCell; use super::player::{Asset}; #[derive(Eq, PartialEq, Debug, Clone, Copy)] pub enum SquareType { ChanceCard, CommunityCard, Corner, Station, Street, Tax, Utility } #[derive(Eq, PartialEq, Debug)] pub struct Suburb { // Name and building price (per building) color...
true
d4a01a7ed74c67ab9f7cbb693d43aae761ae646a
Rust
micahsmith/aoc19
/src/three.rs
UTF-8
3,234
3.578125
4
[]
no_license
use std::cmp; use std::collections::{HashMap, HashSet}; use std::i32; pub fn start(input: &str) { let (wire_one, wire_two) = format_input(input); let wire_one_pm = get_point_map(&wire_one); let wire_two_pm = get_point_map(&wire_two); let intersection = get_map_key_intersection(&wire_one_pm, &wire_two...
true
70261a3128792bd8321d8675c9a3f24899d1275d
Rust
ilslv/rust-incubator
/3_ecosystem/3_10_threads/src/main.rs
UTF-8
1,432
2.953125
3
[]
no_license
use std::sync::mpsc; use std::thread; use rand::{thread_rng, Rng}; use rayon::prelude::*; struct Producer(mpsc::Receiver<[[u8; 64]; 64]>); impl Producer { fn new() -> Self { let (tx, rx) = mpsc::channel(); thread::spawn(move || loop { let mut matrix = [[0_u8; 64]; 64]; fo...
true
430fc2bb7ad2c4eef360f0f5487d93819d584c71
Rust
tempbottle/rust-http2
/src/rc_mut.rs
UTF-8
559
3.1875
3
[ "MIT" ]
permissive
use std::cell::RefCell; pub use std::cell::RefMut; use std::rc::Rc; /// Convenient wrapper around `Rc` + `RefCell` pub struct RcMut<A>(Rc<RefCell<A>>); impl<A> Clone for RcMut<A> { fn clone(&self) -> Self { RcMut(self.0.clone()) } } impl<A> RcMut<A> { pub fn new(a: A) -> RcMut<A> { RcMut...
true
25e895637bb7a68f269dad618883cad816bcce11
Rust
nixpulvis/hell
/7/feeding/src/game/auto/action.rs
UTF-8
2,209
2.84375
3
[]
no_license
use game::*; use interact::*; impl<'a> Choose<ActionObservation, ActionChoice> for Auto<'a, ActionObservation, ActionChoice> { fn choose(&mut self, observation: &ActionObservation) -> Result<Option<ActionChoice>, ()> { let all_choices = &observation.choices(); trace!("all_choices@Choose<ActionChoic...
true
b15fc818ab67ed78fec47b43f00c923d995116a5
Rust
ecsumed/wrench
/src/plan.rs
UTF-8
1,770
4.28125
4
[]
no_license
/// Plan and distribute requests. /// /// Plan holds the requests and threads of a run. /// It uses the 'distribute' function to spread out the /// requests between threads. /// /// # Example /// /// ```rust /// let plan = Plan::new(3, 100) /// assert_eq!(plan.distribute(), [34, 33, 33]); /// let plan = Plan::new(5, 3...
true
1f71d37f6af40211c2b63cf8de2584e658b5e6ca
Rust
roy-ganz/toql
/crates/core/src/map_key.rs
UTF-8
1,736
4.15625
4
[ "MIT", "Apache-2.0" ]
permissive
//! An iterator that maps entities into keys. use crate::keyed::Keyed; /// This `struct` is created by the [map_key] method on Iterator. See its documentation for more. pub struct MapKeyIter<I> { orig: I, } impl<I> Iterator for MapKeyIter<I> where I: Iterator, I::Item: Keyed, { type Item = <I::Item a...
true
185398a99e02467922ad5bf151fdc1a48ccddfff
Rust
kioco/clickhouse-sql-parser
/tests/lib.rs
UTF-8
3,627
2.890625
3
[ "MIT" ]
permissive
// vim: set expandtab ts=4 sw=4: extern crate clickhouse_sql_parser; use clickhouse_sql_parser::{ self as parser, sql_query, }; use std::fs::File; use std::io::Read; use std::path::Path; fn parse_queryset(queries: Vec<String>) -> (i32, i32) { let mut parsed_ok = Vec::new(); let mut parsed_err = 0; ...
true
e6c6e95edc9381e95e77a3e85cb2d90d160ca2ee
Rust
graphprotocol/graph-node
/graph/src/util/monitored.rs
UTF-8
972
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use prometheus::{Counter, Gauge}; use std::collections::VecDeque; pub struct MonitoredVecDeque<T> { vec_deque: VecDeque<T>, depth: Gauge, popped: Counter, } impl<T> MonitoredVecDeque<T> { pub fn new(depth: Gauge, popped: Counter) -> Self { Self { vec_deque: VecDeque::new(), ...
true
8bb73f67096c361b259fe1adb67db608aa8495f1
Rust
yukinagae/rsmc
/src/distribution/uniform.rs
UTF-8
1,204
3
3
[ "MIT" ]
permissive
extern crate probability; use std::fmt; use self::probability::source; use self::probability::distribution::Sample; use self::probability::distribution::Mean; use self::probability::distribution::Median; use distribution::DistType; /// /// Uniform distribution /// #[derive(Clone, Copy)] pub struct Uniform { pub...
true
a61ba5638ad5a712c2dddc2eb67aff16a31b1f9d
Rust
GTime/cqrs-eventsourcing
/tests/lib.rs
UTF-8
8,186
2.609375
3
[ "MIT" ]
permissive
use async_trait::async_trait; use cqrs_eventsourcing::{ Aggregate, AggregateContext, Command, DomainEvent, Error, FileEventStore, FormatedEvent, GivenThen, Query, QueryProcessor, Store, CQRS, }; use serde::{Deserialize, Serialize}; use std::collections::HashMap; mod mock; #[derive(Debug, Serialize, Deserializ...
true
fffb4112ba9db454bc5e19ec902801788bfbfcb8
Rust
paulkirkwood/rs.parcoursdb
/tests/test_liege_bastogne_liege.rs
UTF-8
1,107
2.625
3
[]
no_license
extern crate parcoursdb; extern crate chrono; #[cfg(test)] mod test { use parcoursdb::liege_bastogne_liege::repository::*; use parcoursdb::classic::{Classic,HillyClassic}; #[test] fn test_liege_bastogne_liege_2018() { let edition = liege_bastogne_liege_2018(); assert_eq!(edition.name()...
true
5479f546c1271f6e5a69d84f6a9453e3029c02b6
Rust
pierrechevalier83/unicode_types
/src/generated/tamil_supplement.rs
UTF-8
10,850
2.921875
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the TamilSupplement block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum TamilSupplement { /// \u{11fc0}: '𑿀' TamilFractionOneThreeDashHundredDashAndDashTwentieth, /// \u{11fc1}: '𑿁' TamilFractionOneOneDashHundredDashAndDashSixtieth, /// \u...
true
518d5199daed15e8588eca86cb5f05d40d8849a0
Rust
mendess/SIRS
/server/src/model/child.rs
UTF-8
1,407
2.578125
3
[]
no_license
use crate::schema::children; use diesel::{backend::Backend, Identifiable, Insertable, Queryable}; use serde::{Deserialize, Serialize}; use std::fmt::{self, Display}; #[derive( Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Identifiable, Queryable, )] #[table_name = "children"] pub struct Chi...
true
1567bea69a3d91d8efd5c9aca26e4f28388af546
Rust
TheAlmightyWale/rust_rendering
/src/objects.rs
UTF-8
549
2.734375
3
[]
no_license
use crate::properties::Color; use crate::properties::Material; use crate::serialization_defs::Vector3Def; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Copy, Clone)] pub struct Sphere { #[serde(with = "Vector3Def")] pub center: cgmath::Vector3<f32>, pub radius: f32, pub m...
true
77abba04cf975c00a2cdcd49f9c229ac08835d4c
Rust
darksv/AdventOfCode2017
/21/src/patterns.rs
UTF-8
6,900
3.703125
4
[]
no_license
extern crate std; #[derive(Debug, Hash, Eq, Clone)] pub struct Pattern { size: usize, pixels: Vec<bool>, } impl Pattern { /// Returns new empty `Pattern` with given size. pub fn new(size: usize) -> Pattern { Pattern { size, pixels: vec![false; size * size], } ...
true
3da6742b5f17efe0e0f57249babde2d30b1b8cc0
Rust
AmossGuy/jam-practice
/src/collision.rs
UTF-8
365
2.515625
3
[]
no_license
use collider::{HbId, HbProfile}; #[derive(Copy, Clone, Debug)] pub struct MyHbProfile { pub id: HbId, } impl HbProfile for MyHbProfile { fn id(&self) -> u64 { self.id } fn can_interact(&self, _other: &MyHbProfile) -> bool { true } fn cell_width() -> f64 { 8. } ...
true
80e3df5f3d5b51e2f7843b55af5a815325358de4
Rust
paholg/dimensioned
/src/build/si.rs
UTF-8
8,827
2.8125
3
[ "MIT" ]
permissive
use super::*; pub fn new() -> System { System { name: "SI", module: "si", doc_prelude: "The International System of Units (SI) Where experimental values are used for constants, the values are obtained from the 2014 values from [The NIST Reference on Constants, Unit, and Uncertainty](http:/...
true
7a1d7d1779524d994c51e1ebe52f8ebec45548b0
Rust
ncalibey/mini-projects
/rust/hurl/src/directories.rs
UTF-8
831
2.671875
3
[]
no_license
use lazy_static::lazy_static; use std::path::{Path, PathBuf}; #[cfg(target_os = "macos")] use std::env; pub struct Directories { config: PathBuf, } impl Directories { fn new() -> Option<Directories> { #[cfg(target_os = "macos")] let config_op = env::var_os("XDG_CONFIG_HOME") .map(...
true
7b483fd239f682d2d35936e1024d9d40071ee20f
Rust
imbrn/building
/tests/redefined_prelude.rs
UTF-8
602
3.4375
3
[ "MIT" ]
permissive
use building::Builder; use std::vec::Vec; type Option = (); type Some = (); type None = (); type Result = (); type Box = (); #[derive(Builder)] pub struct Product { id: i32, name: std::option::Option<String>, #[builder(each = "tag")] tags: Vec<String>, } fn main() { let product = Product::builder...
true
64c343304d003df13ba277da64e6d487908e91c4
Rust
yvt/query_interface
/src/dynamic.rs
UTF-8
3,291
2.96875
3
[]
no_license
use std::collections::HashMap; use std::any::TypeId; use std::sync::{Arc, RwLock}; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use std::cell::RefCell; use VTable; type RegistryKey = (TypeId, TypeId); #[doc(hidden)] #[derive(Default, Clone)] pub struct Registry { entries: HashMap<RegistryKe...
true
d530a8c7767ae53f93813537e4d764551a1338fd
Rust
drbrain/unicornify.rs
/src/unicorn/pose.rs
UTF-8
5,365
2.984375
3
[ "BSD-3-Clause", "MIT", "Python-2.0" ]
permissive
use crate::geometry::Axis; use crate::geometry::DEGREE; use crate::pyrand::Random; use crate::unicorn::Legs; use crate::Sorter; use crate::TV; #[derive(Debug, Clone)] pub enum Pose { RotaryGallop { phase: f64 }, Walk { phase: f64 }, } impl Pose { pub fn new(rand: &mut Random) -> Pose { let kind = ...
true
42471f91bd966d5f9e622532c9b2caed421a3a1f
Rust
run-mojo/redmod
/src/stream.rs
UTF-8
10,235
2.515625
3
[]
no_license
#![allow(dead_code)] use libc; use listpack::*; use rax::*; use sds::*; use std; use std::default::Default; use std::fmt; use std::mem::size_of; use std::ptr; pub struct Stream { pub s: *mut stream, } const STREAM_ID: StreamID = StreamID { ms: 0, seq: 0 }; const STREAM_ID_REF: *const StreamID = &STREAM_ID as *co...
true
95264e337c74d631f1207dde42c68423bdff4d17
Rust
matklad/tokio
/tokio/src/executor/thread_pool/shared.rs
UTF-8
2,534
3.09375
3
[ "MIT" ]
permissive
use crate::executor::park::Unpark; use crate::executor::task::{self, Schedule, Task}; use crate::executor::thread_pool::worker; use std::ptr; /// Per-worker data accessible from any thread. /// /// Accessed by: /// /// - other workers /// - tasks /// pub(crate) struct Shared<P> where P: 'static, { /// Thread ...
true
19db03381f6b2490d207445d3806b44d7442b6a1
Rust
Giovan/lumen
/lumen_runtime/src/otp/erlang/tests/bsl_2/with_small_integer_integer.rs
UTF-8
1,750
3
3
[ "Apache-2.0" ]
permissive
use super::*; use num_traits::Num; #[test] fn with_negative_without_underflow_shifts_right() { with_process(|process| { let integer = process.integer(0b101100111000).unwrap(); let shift = process.integer(-9).unwrap(); assert_eq!( erlang::bsl_2(integer, shift, &process), ...
true
84a6bb6f4d37652d1082f486b31dd101bb11f32b
Rust
RustWorks/rs-data-structure
/src/concurrent/list.rs
UTF-8
3,045
3.3125
3
[ "MIT" ]
permissive
use owned_alloc::OwnedAlloc; use std::mem::ManuallyDrop; use std::ptr::NonNull; use std::sync::atomic::{AtomicPtr, Ordering}; pub struct Node<T> { elem: ManuallyDrop<T>, next: Link<T>, } impl<T> Node<T> { pub fn new(elem: T) -> Self { Node { elem: ManuallyDrop::new(elem), n...
true
4163ea1a1227f37f5a701a2e3f2ca0063e63ed5f
Rust
Tan-YiFan/Rust-By-Example
/src/Rust01_HelloWorld/debug.rs
UTF-8
511
3.21875
3
[]
no_license
#[allow(dead_code)] struct UnPrintable(i32); #[derive(Debug)] #[allow(dead_code)] struct Printable(i32); #[derive(Debug)] struct Structure(i32); #[derive(Debug)] struct Deep(Structure); fn main() { // `Structure` is printable! println!("Now {:?} will print!", Structure(3)); // There is no control over...
true
16dfddd23b45fc9010e31f8757740db0b0d39b41
Rust
sgravrock/adventofcode
/2016/rust/day21-1/src/main.rs
UTF-8
9,289
3.34375
3
[ "MIT" ]
permissive
#![feature(slice_patterns)] fn main() { let instructions = parse_input(INPUT); println!("{}", scramble("abcdefgh", instructions)); } #[derive(PartialEq, Eq, Debug, Clone)] enum Instr { SwapLetter(char, char), SwapPos(usize, usize), Reverse(usize, usize), RotateAbs { dir: Dir, offset: usize }, RotateRel(char), ...
true
31210ea0968332dba2937aab0a20563e683fdb06
Rust
patiences/rusty-bites
/factorial.rs
UTF-8
247
3.515625
4
[]
no_license
fn fact(n: i32) -> i32 { if n < 1 { 1 } else { n * fact(n - 1) } } fn fact_smart(n: i32) -> i32 { (1..n).fold(1, |x, y| x * y) } pub fn main() { println!("{}", fact(10)); println!("{}", fact_smart(10)); }
true
f6d3a86b077286ab12093a6ca76b243640d5b031
Rust
shamansir/rust-playground
/17_3.rs
UTF-8
711
3.5625
4
[]
no_license
fn main() { trait Printable { fn print(&self); } impl Printable for int { fn print(&self) { println!("{}", *self); } } { fn print_all<T: Printable>(printable_things: ~[T]) { for thing in printable_things.iter() { thing.print(); } ...
true
418ba3b4ca07c0333cb1df07a3cb583ee568b68f
Rust
TooManyBees/rust-openni2
/src/types.rs
UTF-8
8,257
2.8125
3
[]
no_license
use std::os::raw::c_int; use std::fmt; use openni2_sys::*; use super::get_extended_error; /// Error state for external OpenNI2 C functions #[derive(Debug, Clone)] pub enum Status { /// Success Ok, /// Some error with a message set by OpenNI2 Error(String), NotImplemented, /// Attempted to set a...
true
7ddc1ab2ae0d998a07aeb632dccee846e4be73ba
Rust
KeAiMianYang/work_repo_training
/Rust/book/16_01_concurrency/sync-send/src/main.rs
UTF-8
887
3.4375
3
[]
no_license
use std::marker::{Sync, Send}; fn main() { println!("Hello, world!"); } // the Send marker trait is implemented to allow ownership transfert between threads // almost every type is Send, excepted a few Exceptions, among them Rc // any type entirely composed of Send types is marked as Send // almost all primitive...
true
c72cbe74dceef5e82ddad68a9a2377eb8cadc3a9
Rust
pdx-cs-sound/synthkit
/src/sampler.rs
UTF-8
8,071
2.9375
3
[ "MIT" ]
permissive
// Copyright © 2019 Bart Massey // [This program is licensed under the "MIT License"] // Please see the file LICENSE in the source // distribution of this software for license terms. //! Time stretching and pitch shifting of an audio sample. use std::convert::TryFrom; use std::f32::consts::PI; use dsp::{fft, signal,...
true
ed6e961183ff14042b055e4ef10502911c58cb01
Rust
lucasalj/kvs
/src/cp/mod.rs
UTF-8
20,507
3.234375
3
[ "MIT" ]
permissive
//! Key-Value Store Communication Protocol (KVSCP) //! The messages communicated in this protocol follows the format. //! Byte index(es) from the MSB to LSB: Meaning //! 0: ProtocolHeader //! 1: MessageType (Bit7 => 0: Request, 1: Response; Bits[0..6] => Command) //! 2-: The actual payload content //! Note: All the le...
true
94cb6bec209cb4ec5730e894bd02ecfc34dfc529
Rust
treydempsey/fan_control
/src/fan_control.rs
UTF-8
3,540
3
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader, Seek, SeekFrom}; use anyhow::{Context, Result}; use crate::config::Config; use log::debug; use rppal::pwm::{Channel, Polarity, Pwm}; pub struct FanControl<'c> { pub config: &'c Config, thermal_reader: BufReader<File>, temperature: f64, outside_dead_...
true
287337cb89a0a667b4729e87ddb57e1b4ad39794
Rust
joncv/MeiliSearch
/meilisearch-http/src/lib.rs
UTF-8
8,502
3.296875
3
[ "MIT" ]
permissive
//! # MeiliSearch //! Hello there, future contributors. If you are here and see this code, it's probably because you want to add a super new fancy feature in MeiliSearch or fix a bug and first of all, thank you for that! //! //! To help you in this task, we'll try to do a little overview of the project. //! ## Milli //...
true
c2c4dc9fd6b16fbbed306d5c07e0152a76756a25
Rust
chuck-flowers/worm
/worm/src/sql/values.rs
UTF-8
3,475
3.359375
3
[ "MIT" ]
permissive
use core::fmt::Display; use core::fmt::Formatter; use core::fmt::Result as FmtResult; /// A raw SQL value. pub enum SqlValue { /// A simple `true` or `false` value. #[cfg(feature = "sql-value-bool")] Boolean(bool), /// A 4-byte numeric value with a 'floating' decimal value. #[cfg(feature = "sql-val...
true
e8f3d4f42a5e08fdaa867a345b5df72b6dd4053e
Rust
arizuk/programming-contest-solutions
/atcoder/tenka1_2019/F/main.rs
UTF-8
2,940
2.828125
3
[]
no_license
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read...
true
7c58e4fd908cad97e6559ace699e07bc17d75a81
Rust
arlopurcell/zax
/src/chunk.rs
UTF-8
15,216
3.34375
3
[]
no_license
use std::convert::{TryFrom, TryInto}; #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum ByteCode { Return(u8), PrintInt, PrintFloat, PrintBool, PrintObject, Constant(u8, u8), NegateInt, AddInt, SubInt, MulInt, DivInt, NegateFloat, AddFloat, SubFloat, MulF...
true
9e9356ec8d610ce1938e6abd57a1ff4eb1f36556
Rust
sugyan/leetcode
/problems/0274-h-index/lib.rs
UTF-8
500
3.3125
3
[]
no_license
pub struct Solution {} impl Solution { pub fn h_index(citations: Vec<i32>) -> i32 { let mut citations = citations; citations.sort_unstable(); for i in (0..citations.len()).rev() { if citations[citations.len() - i - 1] > i as i32 { return i as i32 + 1; ...
true
ed923a3d7d6594c92d284a463bb629095fe32bc3
Rust
arrayfire/arrayfire-rust
/src/core/dim4.rs
UTF-8
4,092
3.546875
4
[]
permissive
use std::fmt; use std::ops::{Index, IndexMut}; #[cfg(feature = "afserde")] use serde::{Deserialize, Serialize}; /// Dim4 is used to store [Array](./struct.Array.html) dimensions #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "afserde", derive(Serialize, Deserialize))] pub struct Dim4 { dims: [u64; 4],...
true
2b4b2bdca8ec0c5db1d7bf2dd0e6b8c01f603eb3
Rust
funmaker/Project39-ar
/src/utils/input.rs
UTF-8
325
2.828125
3
[ "MIT" ]
permissive
use crate::application::Key; pub fn num_key(num: usize) -> Key { match num { 0 => Key::Key0, 1 => Key::Key1, 2 => Key::Key2, 3 => Key::Key3, 4 => Key::Key4, 5 => Key::Key5, 6 => Key::Key6, 7 => Key::Key7, 8 => Key::Key8, 9 => Key::Key9, n => panic!("Invalid numeric key: {}", n), }...
true
ebd0e5921f5e4bc0d4a08310fe5e4b72a4975686
Rust
fruitbox12/cosmwasm-gateway
/contracts/token-factory/src/state.rs
UTF-8
1,417
2.625
3
[ "Apache-2.0" ]
permissive
use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{CanonicalAddr, HumanAddr, ReadonlyStorage, StdError, StdResult, Storage, from_slice}; use cosmwasm_storage::{ singleton, singleton_read, PrefixedStorage, ReadonlyPrefixedStorage }; pub static KEY_CONFIG: &[u8] = b"owner"; pub static...
true
0f598baac73863e1abc0730ad974c992a658fff6
Rust
louisdewar/logo
/src/tests/parse.rs
UTF-8
762
3.203125
3
[]
no_license
use crate::program::Program; #[test] fn parse_basic() { // This test should contain every command, to make sure that it is parsed and then it is able to output the original code let code = "fd 100 clear rt 90 clear_colour 255 0 0 fd 300 set_colour 25 50 255 set_pos 50 50 repeat 50 [pu fd 20 pd rt 45 fd 50]"; ...
true
200200d0669ee33564a092053f8c7a3323bb5a0e
Rust
DesmondWillowbrook/rs-reservoir-sampling
/src/lib.rs
UTF-8
2,872
3.4375
3
[ "Unlicense" ]
permissive
#[cfg(feature = "unweighted")] pub mod unweighted { pub mod core; use rand::thread_rng; /// An implementation of Algorithm `L` (https://en.wikipedia.org/wiki/Reservoir_sampling#An_optimal_algorithm) /// # Parameters: /// - Type implementing `std::iter::Iterator` as *source*, /// -...
true
fd356ad1965e4223243379c7786403c200ad7bc1
Rust
DanielD00/pbni-rs
/src/object.rs
UTF-8
100,003
2.59375
3
[ "BSD-2-Clause" ]
permissive
use crate::{ bindings::*, invoker::{ObjectEvent, ObjectMethod}, session::AsMethodName, value::FromValueOwned, * }; use std::{ cell::{Cell, RefCell}, ops::{Deref, DerefMut}, rc::Rc }; /// 对象实例的引用 pub struct Object<'obj> { ptr: pbobject, group: Cell<Option<pbgroup>>, cls: pbclass, session: Sessio...
true
854ccbc407eefd69b2366b7c35eb90efda3a51e7
Rust
rust3ds/ctru-rs
/ctru-sys/src/result.rs
UTF-8
1,069
2.875
3
[ "Zlib" ]
permissive
//! Ports of macros in //! <https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/result.h> use crate::Result; /// Checks whether a result code indicates success. pub fn R_SUCCEEDED(res: Result) -> bool { res >= 0 } /// Checks whether a result code indicates failure. pub fn R_FAILED(res: Result) -...
true
10c4f9ebc1b63fd554cb5d9062d0d0c3369d49b1
Rust
MirecIT/amethyst
/amethyst_rendy/src/batch.rs
UTF-8
13,733
3.15625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Module containing structures useful for batching draw calls //! in scenarios with various known assumptions, e.g. order independence. use std::{ collections::hash_map::Entry, iter::{Extend, FromIterator}, ops::Range, }; use derivative::Derivative; use smallvec::{smallvec, SmallVec}; #[cfg(feature = "pr...
true
7474a600ed079553651362626ab1266341caf990
Rust
lightning-project/lightning
/src/planner/distribution/replicate.rs
UTF-8
2,755
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Internals for [`ReplicateDist`]. use super::*; use itertools::Itertools; /// Distribution that replicates data across all devices. #[derive(Copy, Clone, Debug)] pub struct ReplicateDist<P = AllNodes> { places: P, } impl ReplicateDist { pub fn new() -> Self { Self::with_memories(AllNodes) } } ...
true
65972179a23dea0ad75d4b220456d39067de476a
Rust
saarw/onig_leak
/src/main.rs
UTF-8
1,138
2.78125
3
[]
no_license
extern crate onig; use onig::{Syntax, RegexOptions, Regex}; use std::ops::BitOr; use onig::{MatchParam, Region, SearchOptions}; fn find_no_panic(regex: &Regex, value: &str) -> Option<(usize, usize)> { let match_param = MatchParam::default(); let mut region = Region::new(); let result = regex.search_with_p...
true
26280c4cc486597304085411f099fa2eda5f7fce
Rust
AndrewMendezLacambra/rust-programming-contest-solutions
/atcoder/agc010_c.rs
UTF-8
2,259
3.3125
3
[]
no_license
use std::cmp; fn main() { let s = std::io::stdin(); let mut sc = Scanner { stdin: s.lock() }; let n = sc.read(); let a: Vec<u64> = sc.vec(n); if n == 2 { if a[0] == a[1] { println!("YES"); } else { println!("NO"); } return; } let mut ...
true
0554378d9d0813715dca798171ca10367dc4080b
Rust
jtimon/rustlnd
/tests/argman.rs
UTF-8
11,646
3.015625
3
[ "MIT" ]
permissive
/// Let's make sure ArgMan behaves the way is supposed to in a way that's simple to read use rustlnd::argman; use std::collections::HashMap; #[test] fn test_get_str_arg() { let raw_args = vec!["binname".to_string(), "-aaa=EXPECTED_STR".to_string()]; let mut g_args = argman::ArgMan::new(); g_args.add_arg...
true
b446be70a413bff690a0d97d081f41096aa6b30d
Rust
lorenz-h/six_slots
/src/main.rs
UTF-8
3,532
2.765625
3
[]
no_license
use std::str::FromStr; use rumqtt::{MqttClient, MqttOptions, QoS, Notification}; use serde::{Serialize, Deserialize}; use rustling_ontology::*; use rustling_ontology_json_utils::SlotValue; #[derive(Serialize, Deserialize, Debug)] struct Task { uid: i32, statement: String, slot_kinds: Vec<String>, } #[der...
true
5db89210a13e346fcb049df70323917d911646da
Rust
mrxiaozhuox/dorea
/src/bin/server.rs
UTF-8
2,589
2.53125
3
[ "MIT" ]
permissive
use clap::{App, Arg}; use dorea::server::{DoreaServer, ServerOption}; use dorea::DOREA_VERSION; use std::path::PathBuf; const TEMPLATE: &str = " ⎐ {bin} - (V{version}) ⎐ USAGE: {usage} FLAGS: {flags} OPTIONS: {options} Dorea-Core: https://github.com/mrxiaozhuox/dorea.git Dorea-Repo: https://github.com/doreadb/ ...
true
1646dd805d7eb22f645b501a0bdaaec69d62d696
Rust
kasumi8pon/atcoder_practice
/abc/abc306/src/bin/a.rs
UTF-8
182
2.609375
3
[]
no_license
use proconio::input; use proconio::marker::Chars; fn main() { input! { n: usize, s: Chars } for i in 0..n { print!("{}{}", s[i], s[i]); } }
true
dc514b5dd95ea024ac6558a3b67927382ef17b99
Rust
gerrymanoim/advent_of_code
/2021/rust/day11/src/main.rs
UTF-8
2,329
3.1875
3
[]
no_license
use std::collections::HashSet; use utils::{stdin_to_str_vec, Grid}; fn step(g: &mut Grid) -> usize { let mut flashed = HashSet::<(usize, usize)>::new(); let mut to_flash = Vec::<(usize, usize)>::new(); // Add one to every element for p in g.data.iter_mut() { p.value += 1; if p.value > ...
true
87f144138bea0c9b718a1b50a053d158d2abdc8a
Rust
tglanz/rust-learn
/snake/engine/src/tiles.rs
UTF-8
209
2.984375
3
[]
no_license
use std::vec::Vec; #[derive(PartialEq, Clone, Copy)] pub enum Tile { Empty, // Freely move on Occupied, // Die on impact Food, // Get longer } pub type Tiles = Vec<Tile>;
true
b6f4bac6df6b4a05d396f098fc2330db88609cd6
Rust
rdrsss/find-and-replace
/src/fnr.rs
UTF-8
3,010
3.171875
3
[]
no_license
/// Cli app for find and replace utility. /// /// TODO : /// * console highlighting of words, and color formatting for output. // Include crates extern crate log; extern crate clap; use std::path; use std::env; use std::string; // Pull in curator module pub mod curator; /// build_cli build's the cli app. fn...
true
2da3fe5b5a78f23f0c784e873a94a9122e3b14ad
Rust
moobaaclub/solana-fantasy-app
/contracts/solana-fantasy-sports/src/instructions/structures/player.rs
UTF-8
3,348
2.84375
3
[]
no_license
//! State transition types use crate::instructions::*; use crate::state::structures::Position; use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs}; use byteorder::{ByteOrder, LittleEndian}; use num_enum::TryFromPrimitive; use solana_program::{ program_error::ProgramError, program_pack::...
true
bed15f838839a7c0f93cdaf88dd61cbe1c59ed75
Rust
nushell/nushell
/crates/nu-command/tests/commands/last.rs
UTF-8
2,118
2.9375
3
[ "MIT" ]
permissive
use nu_test_support::fs::Stub::EmptyFile; use nu_test_support::nu; use nu_test_support::playground::Playground; #[test] fn gets_the_last_row() { let actual = nu!( cwd: "tests/fixtures/formats", "ls | sort-by name | last 1 | get name.0 | str trim" ); assert_eq!(actual.out, "utf16.ini"); } ...
true
76e6333029bfd20705210d7e07f00b12c2d75274
Rust
emanguy/Simple-Parser
/src/parser/parse_data.rs
UTF-8
806
2.828125
3
[]
no_license
#[derive(PartialEq, Eq, Clone)] pub struct SymbolData { pub representation: char, pub precedence: u8, } pub enum TokenizationError { EndOnInfixSymbol, BadToken { token: char }, } pub enum Token { Value(i32), Symbol(SymbolData), } pub const MULTIPLY: SymbolData = SymbolData { representatio...
true
5e3f7d58fbbe4f5739f4a88047a2d9d31beaf7b4
Rust
MarimeGui/pac
/src/decompression/utils.rs
UTF-8
911
2.703125
3
[]
no_license
use std::io::{Read, Result}; use std::mem::transmute; // Reimplementation of x86 SHLD instruction pub fn shld(dest: u32, src: u32, count: u8) -> u32 { let mut out = dest; out <<= count; out |= src >> (32 - count); out } pub fn load_new_data<R: Read>(reader: &mut R, pak_k: &mut u32, pak_m: &mut u32) ->...
true
d0dd4dda9db360122d013326e05ab614a69f2708
Rust
sugyan/leetcode
/problems/0228-summary-ranges/lib.rs
UTF-8
930
3.5625
4
[]
no_license
pub struct Solution {} impl Solution { pub fn summary_ranges(nums: Vec<i32>) -> Vec<String> { let mut answer = Vec::new(); let mut i = 0; while i < nums.len() { let n = nums[i]; while i < nums.len() - 1 && nums[i + 1] == nums[i] + 1 { i += 1; ...
true
4966ae0efed13207895d0509c021707cd7af200b
Rust
rsbt/rsbt
/_rsbt-app/src/torrent/torrent_process.rs
UTF-8
677
2.546875
3
[ "Unlicense", "MIT", "CC-BY-NC-ND-4.0" ]
permissive
use crate::{ announce::Announces, peer::Peers, statistic::Statistics, storage::Storage, torrent::TorrentHeader, }; use std::sync::Arc; pub struct TorrentProcess { header: Arc<TorrentHeader>, peers: Peers, announces: Announces, storage: Storage, statistics: Statistics, } impl TorrentProcess...
true
f7fe9be11fea154f903e532199e4fdd53bb78e50
Rust
yishn/adventofcode
/2015/09.rs
UTF-8
2,342
3.578125
4
[ "MIT" ]
permissive
use std::fs::File; use std::io::Read; use std::collections::HashMap; fn get_input() -> std::io::Result<String> { let mut file = File::open("09.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; Ok(contents) } type Cities<'a> = Vec<&'a str>; type Distances<'a> = HashMap<(&'...
true
80f3ec8c44efc857d3d838ca8db0cb35b3bfc7c5
Rust
zellij-org/zellij
/zellij-utils/src/data.rs
UTF-8
35,043
2.96875
3
[ "MIT" ]
permissive
use crate::input::actions::Action; use crate::input::config::ConversionError; use clap::ArgEnum; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fmt; use std::path::{Path, PathBuf}; use std::str::FromStr; use strum_macros::{Display, EnumDiscriminants, EnumIter, EnumString, ToStri...
true
e14f971728348b9d77446986c433b0f3fce5723d
Rust
martypapa/debug-tree
/examples/panic.rs
UTF-8
569
2.65625
3
[]
no_license
use debug_tree::*; fn i_will_panic() { add_branch!("Here are my last words"); add_leaf!("Stay calm, and try not to panic"); panic!("I told you so...") } fn main() { // output to file at the end of this block defer_write!("examples/out/panic.txt"); // print at the end of this block { ...
true
8fa0d6b3df58a8f1028ba65644f035d4d8b4dc1f
Rust
rwarnking/pir-task-fbecker-rwarnking
/sheet11/task2/src/game_logic/ai.rs
UTF-8
3,701
3.4375
3
[]
no_license
use game_logic::{Board, Symbol, WIN_CONDITIONS, Position}; use game_logic::types::{Player, PlayerType}; use game_logic::Position::*; use game_logic::Symbol::*; /// Returns a dumb move that just looks for an empty field /// in a line that no other marks. fn get_dumb_move(board: &Board) -> Position { for outer in 1....
true
50fdb330d384369fe7a177f0237f71d6a63b87cb
Rust
Wonskcalb/rusty-brain
/pastes/generated id/bar.rs
UTF-8
177
2.703125
3
[]
no_license
use std::fs; fn main() -> std::io::Result<()> { for entry in fs::read_dir(".")? { let dir = entry?; println!("{:?}", dir.path()); } Ok(()) }
true