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
cf5f59e44dadadf8c77e1e098b9b04b222922774
Rust
zzliujianbo/dgmrcp
/src/vendor_params.rs
UTF-8
3,933
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Serde support for UniMRCP vendor specific parameters. use crate::ffi; use serde::{ de::{DeserializeSeed, MapAccess, Visitor}, Deserialize, Deserializer, }; pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("serde: {0}")] Serde(String),...
true
d1078fa2c10c0ec08d06f7cbbb4a9f0219dce376
Rust
forchain/rust-netproxy
/iana/src/number/status.rs
UTF-8
3,230
2.984375
3
[]
no_license
// pub static IP_NUMBER_STATUS_SET: [&'static str; 11] = ["afrinic", "allocated", "apnic", "arin", "assigned", "available", "iana", "ietf", "lacnic", "reserved", "ripencc"]; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Status { Afrinic, Allocated, Apnic, Arin, Assigned, Available, ...
true
069e47adccd8f72788f5211e89478cc923677625
Rust
qnighy/gotham-todolist-example
/gotham-session-redis/src/lib.rs
UTF-8
4,088
2.65625
3
[]
no_license
extern crate gotham; extern crate redis_async; extern crate tokio; use tokio::prelude::*; use gotham::middleware::session::{Backend, NewBackend, SessionError, SessionIdentifier}; use redis_async::client::paired::{paired_connect, PairedConnection}; use redis_async::resp::RespValue; use std::io; use std::net::{SocketAd...
true
10ebc6db5b073bab45ee35e684ed67e615c77d1d
Rust
dennisss/dacha
/pkg/math/src/geometry/half_edge.rs
UTF-8
81,328
2.96875
3
[ "Apache-2.0" ]
permissive
use alloc::vec::Vec; use core::cmp::Ordering; use core::f32::consts::PI; use core::fmt::Debug; use core::hash::Hash; use std::collections::HashMap; use std::collections::HashSet; use common::loops::*; use crate::geometry::convex_hull::turns_right; use crate::geometry::entity_storage::*; use crate::geometry::line_segm...
true
e9162953dd74814c645ac4d16d535d2ff0caea5d
Rust
hamidr/rmafia
/src/in_memory_room.rs
UTF-8
3,470
3.03125
3
[]
no_license
use crate::room::*; use crate::scenario::*; use crate::waiting::GodWayRef; use crate::waiting::PlayerId; use std::collections::BTreeMap; struct Player { powers: Vec<Power>, connection: GodWayRef } impl Player { fn new(con: GodWayRef) -> Self { Self { powers: Vec::new(), ...
true
20819893bbe213df50614162b93d43698b0c5837
Rust
hacspec/hacspec
/examples-unsafe/src/ec/arithmetic.rs
UTF-8
3,686
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use hacspec_lib::*; #[derive(Clone, Copy, PartialEq, Debug)] pub struct Jacobian<T: UnsignedIntegerCopy>(pub T, pub T, pub T); #[derive(Clone, Copy, PartialEq, Debug)] pub struct Affine<T: UnsignedIntegerCopy>(pub T, pub T); fn jacobian_to_affine<T: UnsignedIntegerCopy>(p: Jacobian<T>) -> Affine<T> { let (x, y, ...
true
9c56c8bb6411dea23177108ca91a0e47a6abc385
Rust
troiganto/scenarios
/src/cartesian.rs
UTF-8
14,240
3.453125
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Nico Madysa. // // 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 wri...
true
513b65ce77f70ec5b1af878bf5bec1f27c3db9c5
Rust
gifnksm/sabios
/src/sync/spin_mutex.rs
UTF-8
954
3.03125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate::prelude::*; /// A wrapper around `spin::Mutex` which panics immediately when deadlock detected. #[derive(Debug, Default)] pub(crate) struct SpinMutex<T: ?Sized>(spin::Mutex<T>); pub(crate) type SpinMutexGuard<'a, T> = spin::MutexGuard<'a, T>; impl<T> SpinMutex<T> { pub(crate) const fn new(value: T) ->...
true
3bb1911fdc6cab4c476c312c0a66b92577566887
Rust
RoryABrittain/Advent-of-code-2020
/src/thirteen.rs
UTF-8
2,148
3.15625
3
[]
no_license
use std::fs; pub fn run() { let test_data = "939\r\n7,13,x,x,59,x,31,19"; assert_eq!(first_bus(&test_data), 295); let raw_data = fs::read_to_string("thirteen_data.txt") .expect("Can't find file"); println!("{}", first_bus(&raw_data)); assert_eq!(time_for_all_bus...
true
a7aa459263938f794fe4877b1f0fcbad3bb69ccd
Rust
maurer/bap-rust
/src/basic.rs
UTF-8
41,309
2.78125
3
[ "MIT" ]
permissive
//! This module provides the basic interace to BAP //! It essentially re-exports all functions from `bap-bindings` with //! safety wrappers. use bit_vec::BitVec; use enum_primitive::FromPrimitive; use std::cell::Cell; use std::ffi::{CStr, CString}; use std::fmt; use std::marker::PhantomData; use std::ptr::{null, null_...
true
ad16e32006138d6215641157893c6a93a9bec13c
Rust
dylemma/procedural-dungeon-rs
/src/systems/player.rs
UTF-8
2,804
2.53125
3
[]
no_license
use bevy::prelude::*; use crate::convert::set_2d_translate; use crate::nav::{Navigation, NavigationSpeed}; use crate::systems::levelgen::ResetNavigationOnLayout; use crate::systems::nav::{NavigateTo, PlayerNavigationWaypoint}; pub struct PlayerPlugin; impl Plugin for PlayerPlugin { fn build(&self, app: &mut App)...
true
5b646e2258bd8a8fb36423da5a80b9cc42c1e200
Rust
wilsonk/rust
/src/comp/middle/shape.rs
UTF-8
3,867
2.75
3
[ "BSD-1-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "MIT", "BSD-2-Clause", "bzip2-1.0.6", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// The "shape" of a type is best defined as "how a value of a type looks from // the standpoint of a certain built-in operation". // // This is used to collapse glues that would otherwise be separate. For // instance, a boxed tuple of 3 ints and a boxed tuple of 3 uints look the // same as far as reference count manipu...
true
397584bd2280dfd1bc841bcb04fcce6c4c20e849
Rust
PokerN/minimad
/src/composite.rs
UTF-8
8,165
3.390625
3
[ "MIT" ]
permissive
/// a composite is a group of compounds. It can be a whole line, /// or a table cell /// use crate::{ compound::{Alignment, Compound}, line_parser::LineParser, }; /// The global style of a composite #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum CompositeStyle { Paragraph, Header(u8), // never 0...
true
ae79cc1a69728ff0dd572c628e53cce11b4f0bef
Rust
serenity-rs/serenity
/src/model/application/interaction/ping.rs
UTF-8
917
2.90625
3
[ "ISC" ]
permissive
use serde::{Deserialize, Serialize}; use crate::model::application::interaction::InteractionType; use crate::model::id::{ApplicationId, InteractionId}; /// A ping interaction, which can only be received through an endpoint url. /// /// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-resp...
true
062a6be1b603ef29648e725d8cb6ecdc79fa9d0b
Rust
mottodora/contest
/yukicoder/4.rs
UTF-8
886
3.046875
3
[]
no_license
fn getline() -> String{ let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); ret } fn getvec(string: String) -> Vec<i32> { string.trim().split_whitespace() .map(|s| s.parse().unwrap()) .collect() } fn main() { //let n:i32 = getline().trim().parse().unwrap(); ...
true
7fd0bbfec3ae94bcfd8071c42fdeeaf93fec0a80
Rust
gbersac/gomoku_42
/src/display/mouse.rs
UTF-8
2,299
3.125
3
[]
no_license
extern crate piston; use std::fmt::{Formatter, Display, Error}; #[derive(Debug, Clone)] pub struct Mouse { overed: bool, coordinate_cell: (u32, u32), dimension: (u32, u32), } impl Mouse { pub fn new ( sizes: (u32, u32), ) -> Self { let mut event: Self = Default::default(); ...
true
e72ae56a9c26ae41fcb7f0de74bc5b63b216168c
Rust
kvsari/gromit
/src/lib.rs
UTF-8
1,084
3.25
3
[]
no_license
//! Gromit contains geometric operations, traits and data types. //! //! Floats are primarly used for simplicity. But you'll occasionally see `BaseFloat` //! lurking about due to other math libraries being fancy with their scalar types. use std::mem; use derive_getters::Getters; pub mod geop; /// Final vertex data r...
true
71a9a132a9bcbe73d7f3393a9d545467660c6ded
Rust
SINHASantos/wasmer
/lib/cli/src/commands/list.rs
UTF-8
1,549
2.59375
3
[ "MIT" ]
permissive
use clap::Parser; use wasmer_registry::WasmerConfig; /// Subcommand for listing packages #[derive(Debug, Copy, Clone, Parser)] pub struct List {} impl List { /// execute [List] pub fn execute(&self) -> Result<(), anyhow::Error> { use prettytable::{format, row, Table}; let wasmer_dir = ...
true
2d158471122251b75c3219a3ad8a3a6b74e44028
Rust
dmitry-pechersky/algorithms
/codechef/FRMQ_Chef_and_Array.rs
UTF-8
1,868
3.25
3
[]
no_license
use std::{io, str::FromStr, fmt::Debug}; struct RMQ { dp: Vec<Vec<u32>> } fn ilog2(n: usize) -> u32 { usize::BITS - n.leading_zeros() - 1 } impl RMQ { fn new(nums: &[u32]) -> Self { let n = nums.len(); let k = ilog2(n) as usize; let mut dp = vec![Vec::from(nums)]; for j in 1....
true
3fd1be06aa3a7cc355560236f5451d5d2e9d4fea
Rust
bennyboer/worklog
/persistence/src/data_access/sqlite/patch/list/patch1.rs
UTF-8
1,397
2.65625
3
[ "MIT" ]
permissive
use crate::data_access::sqlite::patch::patch::Patch; use rusqlite::{Connection, NO_PARAMS}; use std::error::Error; /// Patch for adding the basic tables logs, log_tags, log_events. pub struct Patch1; impl Patch for Patch1 { fn version(&self) -> i32 { 1 } fn patch(&self, con: &mut Connection) -> R...
true
b8d12a2ad84b1d7bd1bc7555bbb250866d6182f4
Rust
GoldsteinE/linfb
/src/shape.rs
UTF-8
7,296
3.609375
4
[ "MIT" ]
permissive
//! Various drawing primitives use std::convert::TryFrom; use std::ops::{Mul, MulAssign}; use derive_builder::Builder; use downcast_rs::{impl_downcast, Downcast}; use crate::{ Error::{self, *}, Result, }; #[cfg(feature = "text")] pub use crate::text::{Alignment, Caption, CaptionBuilder, FontBuilder}; #[cfg...
true
19afcb761b12e6b164c8dfcdf2af501d4551446a
Rust
NaokiM03/rust-sandbox
/exercises/examples/pulldown-cmark.rs
UTF-8
453
2.546875
3
[]
no_license
use pulldown_cmark as Cmark; fn main() { let input = "Hello world, this is a ~~complicated~~ *very simple* example."; let mut options = Cmark::Options::empty(); options.insert(Cmark::Options::ENABLE_STRIKETHROUGH); let parser = Cmark::Parser::new_ext(input, options); let mut html_output = String:...
true
82ec0b4188dafe2e519041a8c07744d2388e310c
Rust
gnoliyil/fuchsia
/src/connectivity/lowpan/lib/openthread_rust/src/ot/net_data.rs
UTF-8
2,261
2.671875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::prelude_internal::*; /// The maximum length of Thread network data, in bytes. pub const MAX_NET_DATA_LEN: usize = 255; /// Methods from the [O...
true
70508b70d635ffe6c65b6d74c70713740118587f
Rust
cqueirolo/21C1-Stormtroopers
/redis_server/src/command/db_string_cmd/set_cmd.rs
UTF-8
2,344
3.015625
3
[]
no_license
//! Sets a string value to a given key. //! //! Example: //! ```text //! > set key value //! OK //! > get key //! value //! ``` use crate::command::cmd_trait::Command; use crate::command::command_builder::CommandBuilder; use crate::command::command_parser::ParsedMessage; use crate::errors::run_error::RunError; use crat...
true
f290c1a1b1ff1c28f48da9566336e6aa8d5e23cf
Rust
tomsik68/secret-service-rs
/examples/example.rs
UTF-8
1,515
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//Copyright 2016 secret-service-rs Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://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 acc...
true
b52f71ebe5433a7e9df1cf1b10264b461ac5ff84
Rust
snorrwe/snippets
/collections/bitroomgrid.rs
UTF-8
6,667
3.6875
4
[ "MIT" ]
permissive
//! Dependencies: `serde` //! //! A 50×50 binary grid meant to be used to flag tiles in a room //! //! Has basic compression built in too for more compact serialization use serde::de::{self, Deserialize, Deserializer, Visitor}; use serde::ser::{self, Serialize, Serializer}; use std::fmt::{self, Write}; const ROWS: u...
true
55b12cb8d9141d67cd94be40c0697560a2ec63fd
Rust
sshyran/diesel
/diesel/src/query_builder/select_clause.rs
UTF-8
3,484
3.0625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::backend::Backend; use crate::expression::{Expression, SelectableExpression}; use crate::query_builder::*; use crate::query_source::QuerySource; #[derive(Debug, Clone, Copy, QueryId)] pub struct DefaultSelectClause; #[derive(Debug, Clone, Copy, QueryId)] pub struct SelectClause<T>(pub T); /// Specialised va...
true
9b5d1d73655c20d530b08b8dea2eaa0af2b0eaaa
Rust
nonvirtualthunk/rust-survival-hex
/arx_graphics/src/core.rs
UTF-8
17,069
2.75
3
[]
no_license
use camera::*; use common::color::*; use common::hex::CartVec; use common::prelude::*; use common::Rect; use find_folder; use gfx; use gfx_device_gl; use itertools::Itertools; use piston_window::*; use piston_window::math; use piston_window::TextureSettings; use piston_window::types; use rusttype as rt; use rusttype::g...
true
c8766a0b4dcfb70b248aa5ed79f63075a01e3ea5
Rust
EFanZh/LeetCode
/src/problem_0636_exclusive_time_of_functions/mod.rs
UTF-8
1,138
2.6875
3
[]
no_license
pub mod stack; pub trait Solution { fn exclusive_time(n: i32, logs: Vec<String>) -> Vec<i32>; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ( ( 1, &["0:start:0", "0:start:2", "0:en...
true
981e42cf6d49cd1e48e57e9cebdabb3f58da6d32
Rust
GopherJ/mijia-homie
/homie-device/examples/light.rs
UTF-8
1,605
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use homie_device::{ColorFormat, ColorRGB, HomieDevice, Node, Property, SpawnError}; use rumqttc::MqttOptions; #[tokio::main] async fn main() -> Result<(), SpawnError> { pretty_env_logger::init(); let mqttoptions = MqttOptions::new("homie_example", "test.mosquitto.org", 1883); let mut builder = Ho...
true
1830cd541b20555350cb5a001f99b989e839ee2c
Rust
Arsalanali-26/Rust-Q2-Assignment01
/Q2-assignment01/assignment_01/src/main.rs
UTF-8
1,171
3.390625
3
[]
no_license
#[derive(Debug)] struct NewsArtical { author:String, content:String } #[derive(Debug)] struct Tweet { username:String, content:String } pub trait Summary{ fn summarize(&self) -> String; } impl Summary for NewsArtical{ fn summarize(&self) ->...
true
39dcaa17d9f42f910688c53086f5d8d735c0849f
Rust
christian-blades-cb/aoc-2020
/rust/src/main.rs
UTF-8
3,457
2.65625
3
[]
no_license
use std::fs::File; mod day1; mod day10; mod day11; mod day12; mod day13; mod day14; mod day15; mod day16; mod day17; mod day2; mod day3; mod day4; mod day5; mod day6; mod day7; mod day8; mod day9; fn main() { let day1input = day1::parseday1("day1.input"); println!("day1p1: {}", day1::day1p1(&day1input)); p...
true
cebe55f3724c2b42a7cae44bb7bcf789d66e404a
Rust
jroesch/tvm-cli-rs
/src/main.rs
UTF-8
825
2.671875
3
[]
no_license
use std::path::{Path, PathBuf}; use structopt::StructOpt; mod const_eval_no_pass; /// A simple tool which applies a pass to a Relay program and /// serialized the output to disk. #[derive(StructOpt, Debug)] #[structopt(name = "tvm_opt")] struct Opt { /// The input file path. #[structopt(short, long)] inpu...
true
1d858f5e6d49de9393f855008afe26ab14cd83d2
Rust
NVSL/Corundum
/examples/mapcli/map/pbtree.rs
UTF-8
18,138
2.546875
3
[ "Apache-2.0" ]
permissive
// //! btree.rs -- textbook implementation of btree /w preemptive splitting // //! equivalent to [btree example] from PMDK. // //! // //! [btree example]: https://github.com/pmem/pmdk/blob/master/src/examples/libpmemobj/tree_map/btree_map.c // use std::fmt::Debug; // use std::panic::UnwindSafe; // use corundum::stm::J...
true
ec30e6265429756246b15e872560024d933d1c74
Rust
an-death/domain-match
/rust/src/main.rs
UTF-8
2,179
2.96875
3
[]
no_license
#![feature(test)] extern crate test; use test::Bencher; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate glob; use glob::Pattern; use std::assert_eq; use std::env::args; use std::fs::File; use std::io::Read; use std::string::String; const TEMPLATES_FILE: &str = "templ...
true
8b235dbadeb996183195e1f271ac9e1ed3bcf712
Rust
bing050802/space_engineers_calc
/code/gui_iced/src/page/load.rs
UTF-8
1,445
3
3
[]
no_license
use iced::{Align, button, Element}; use crate::storage::Storage; use crate::view::{button, col, h1, h3, row}; use std::ops::Deref; #[derive(Debug)] pub struct Page { load_states: Vec<(String, button::State)>, cancel_button_state: button::State, } #[derive(Clone, Debug)] pub enum Message { Load(String), Cance...
true
591886124987fd10642408ab8f088298ae5df5a9
Rust
isidornygren/ogaboga
/src/wave_generator.rs
UTF-8
1,741
3.109375
3
[ "MIT" ]
permissive
const PI_2: f32 = 2.0 * std::f32::consts::PI; pub type WaveForm = &'static (dyn FnMut(f32) -> f32 + Sync); pub type WaveBox = Box<dyn FnMut(f32) -> f32 + Sync + Send>; pub struct WaveGenerator { sample_rate: u32, waveform: WaveBox, step_size: f32, current_step: f32, } impl WaveGenerator { #[inline] ...
true
d83d0a98775af714990414b58d9b9e6ec1a32559
Rust
torfah/RTLola
/frontend/src/ty/unifier.rs
UTF-8
14,476
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::{StreamTy, TypeConstraint, ValueTy}; use ena::unify::{ EqUnifyValue, InPlace, InPlaceUnificationTable, Snapshot, UnificationStore, UnificationTable, UnifyKey, UnifyValue, }; use log::{debug, trace}; /// Main data structure for the type unfication. /// Implemented using a union-find data structure where ...
true
437a5dd4c80a6f6f7e6f8ba273227645ec9c2254
Rust
bpa/ark-file-parser
/src/object/location.rs
UTF-8
439
3.109375
3
[ "MIT" ]
permissive
use crate::io::Reader; use serde::Serialize; use std::io::{Result, SeekFrom}; #[derive(Debug, Serialize)] pub struct Location { pub x: f32, pub y: f32, pub z: f32, } impl Location { pub fn read(file: &mut dyn Reader) -> Result<Self> { let x = file.read_f32()?; let y = file.read_f32()?;...
true
952db8839b58408b133e671969d7c69c40222169
Rust
IThawk/rust-project
/rust-master/src/test/debuginfo/closure-in-generic-function.rs
UTF-8
1,269
2.546875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// min-lldb-version: 310 // compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print x // gdb-check:$1 = 0.5 // gdb-command:print y // gdb-check:$2 = 10 // gdb-command:continue // gdb-command:print *x // gdb-check:...
true
5a7daed9e9765bc47708c64829fd45672fba211b
Rust
jeffparsons/lapin
/futures/src/client.rs
UTF-8
6,571
2.578125
3
[ "MIT" ]
permissive
use lapin_async; use lapin_async::format::frame::Frame; use std::default::Default; use std::io; use futures::{future,Future,Poll,Stream}; use futures::sync::oneshot; use tokio_io::{AsyncRead,AsyncWrite}; use tokio_timer::Interval; use std::sync::{Arc,Mutex}; use std::time::{Duration,Instant}; use transport::*; use cha...
true
b000494c830573126658f39a43fec3629ee509bd
Rust
CmdrMoozy/bdrck
/bdrck/src/tests/crypto/keystore.rs
UTF-8
5,285
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright 2015 Axel Rasmussen // // 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 w...
true
817421c940876074d6d282ecea211d851801ede2
Rust
graysonhead/metalmon
/src/utils.rs
UTF-8
434
2.796875
3
[]
no_license
use rpassword::read_password; use clap::{ArgMatches}; pub fn get_password_or_prompt(matches: &ArgMatches) -> String { let pass_input = matches.value_of("password"); let password = match pass_input { None => { println!("Type your password:"); let password = read_password().unwra...
true
284babe11be54ba5d34854418b083433271abdb9
Rust
manueldeval/rust_ray
/src/math/src/num.rs
UTF-8
2,211
3.109375
3
[]
no_license
use core::f64; use std::ops::{Add, Div, Mul, Sub}; pub trait Sqrt { fn sqrt(self) -> Self; } impl Sqrt for f32 { fn sqrt(self) -> f32 { f32::sqrt(self) } } impl Sqrt for f64 { fn sqrt(self) -> f64 { f64::sqrt(self) } } pub trait Zero { fn zero() -> Self; } macro_rules! impl...
true
d4dbdcfc0406ecd68295ec5b63f5d63c8e07e941
Rust
jmulcahy/advent-of-code-2017
/day8/src/bin/main.rs
UTF-8
395
2.53125
3
[]
no_license
extern crate day2; extern crate day8; fn main() { let filename = "input.txt"; let input = day2::read_file(filename) .expect(&format!("couldn't open {}", filename)); let data = day8::parse_input(&input).expect("failed to parse data"); let result = day8::process(&data).expect("failed to process d...
true
46f92c4b87f2dbe5b215ec449e0195a34a4af454
Rust
vitvakatu/rust-oids
/src/app/ev.rs
UTF-8
2,649
2.734375
3
[ "Apache-2.0" ]
permissive
use glutin; use frontend::input; use frontend::input::Key; use core::geometry::Position; pub struct GlutinEventMapper; impl GlutinEventMapper { pub fn new() -> Self { GlutinEventMapper {} } } impl input::EventMapper<glutin::Event> for GlutinEventMapper { fn translate(&self, e: &glutin::Event) -> Option<input::E...
true
08cf91ad0b64493d9a0494de370419ba4ed5e620
Rust
mana-eevee/animated
/bittorrent/src/p2p.rs
UTF-8
1,239
2.71875
3
[]
no_license
use serde::{Deserialize, Serialize}; use std::mem::size_of; #[derive(Serialize, Deserialize, Debug)] pub struct PeerHandshake { // This is really the magic string byte count in hex. // The magic string is 19 bytes so 0x13 in hex. pub magic: u8, pub more_magic: [u8; 19], pub reserved_bytes: [u8; 8],...
true
e1fe672db618fa151c0adfed41cc5228f2cbc470
Rust
carllerche/shipit
/src/manifest.rs
UTF-8
810
2.65625
3
[]
no_license
use semver::Version; use serde_derive::Deserialize; use toml; use std::fs::File; use std::io::prelude::*; use std::path::Path; /// Represents the needed `Cargo.toml` data. #[derive(Debug, Deserialize)] pub struct Manifest { pub package: Option<Package>, pub workspace: Option<Workspace>, } #[derive(Debug, Des...
true
3110b88270ef4b0d33e8f70edeb03df705926f9a
Rust
ZetiMente/rust-bert
/src/pipelines/pos_tagging.rs
UTF-8
7,667
2.78125
3
[ "Apache-2.0" ]
permissive
// Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc. // Copyright 2019 Guillaume Becquin // 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 // ...
true
e2ed711518b7ac31a3c08044450deb43b3ea5dc5
Rust
starcoinorg/starcoin
/config/src/helper.rs
UTF-8
2,890
2.53125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use super::*; use names::{Generator, Name}; pub(crate) fn save_config<T, P>(c: &T, output_file: P) -> Result<()> where T: Serialize + DeserializeOwned, P: AsRef<Path>, { let mut file = File::create(output_file)?; fi...
true
34c59e07201ebc2ffee312a2194e9f2fde116a7f
Rust
ANEP-Research/spattern_graph
/src/matrix.rs
UTF-8
5,123
3.15625
3
[]
no_license
// TODO: Add support rayon // use rayon::prelude::*; use std::fmt; use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign}; #[derive(Clone, Debug)] pub struct SquareMatrix { data: Vec<Vec<usize>>, ord: usize, } impl SquareMatrix { pub fn new(n: usize) -> Self { Self { data: vec...
true
c767fd12fc67fdf4c2916abe5a3b7ad8ff79940a
Rust
twe4ked/sort
/src/lib.rs
UTF-8
1,680
3.75
4
[]
no_license
pub fn bubble_sort(list: &mut Vec<usize>) { loop { let mut swapped = false; for i in 0..list.len() { if let Some(j) = list.get(i + 1) { if &list[i] > j { list.swap(i, i + 1); swapped = true; } } }...
true
17c4385c2c16102a9ec5c6944df166d5ee2e6ad7
Rust
follang/fol
/src/syntax/index/reader.rs
UTF-8
628
2.90625
3
[ "MIT" ]
permissive
use std::{ fs::File, io::{self, prelude::*}, }; pub struct BufReader { reader: io::BufReader<File>, } impl BufReader { pub fn open(path: impl AsRef<std::path::Path>) -> io::Result<Self> { let file = File::open(path)?; let reader = io::BufReader::new(file); Ok(Self { reader }) ...
true
299ae335eec5cc40b97478786477baf3e0fcb600
Rust
kuy/minitracer
/src/main.rs
UTF-8
2,111
2.734375
3
[]
no_license
#[macro_use] extern crate approx; mod hittable; mod hittable_list; mod ray; mod sphere; mod vec3; use hittable::Hittable; use hittable_list::HittableList; use ray::Ray; use sphere::Sphere; use vec3::{Color, Point3, Vec3}; fn main() { // Image let aspect_ratio = 16.0 / 9.0; let image_width = 400; let ...
true
a66c29b0ac9c98698a0427d885712881c837e306
Rust
AVerm/tarot_profile
/src/tarot/mod.rs
UTF-8
6,454
3.546875
4
[]
no_license
use std::fmt; // Needed to write custom printing methods for the cards use super::zodiac::Zodiac; // Needed to write the Zodiac -> zodiac card function #[allow(dead_code)] /// Enum representing a Tarot card from the 78-card Rider-Waite deck pub enum RiderWaite { MajorArcana(MajorArcana), MinorArcana(Suit, Rank...
true
9a3fb9048e01896c8a33914cfe68df7652d7f706
Rust
ReinierMaas/morton
/benches/morton.rs
UTF-8
5,080
2.53125
3
[ "MIT" ]
permissive
#[macro_use] extern crate bencher; use bencher::{black_box, Bencher}; use rand::{thread_rng, Rng}; use morton::utils::{idx_tile, idx_tile_tuple}; use morton::{deinterleave_morton, interleave_morton}; fn interleave_1000(b: &mut Bencher) { let x = thread_rng().gen::<u16>(); let y = thread_rng().gen::<u16>(); ...
true
fabb4e355d3ac33507339c59d4a80b636b7ccc86
Rust
jgdavey/prose
/src/lib.rs
UTF-8
439
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
//! # Basic usage //! //! ``` //! extern crate prose; //! //! use prose::{self, FormatOpts}; //! //! let data = "Lot's of string data... to be reformatted"; //! let opts = FormatOpts::with_max_length(25); //! let new_data = prose::reformat(&opts, data); //! //! assert_eq!(new_data, "Lot's of string data...\nto be refor...
true
0667279699746dd33fcc4dd1dc0b77f98e923291
Rust
tclh123/porus
/src/deque.rs
UTF-8
683
3.34375
3
[ "MIT" ]
permissive
pub trait Deque { type Elem; fn is_empty(&self) -> bool; fn push_front(&mut self, elem: Self::Elem); fn pop_front(&mut self) -> Option<Self::Elem>; fn push_back(&mut self, elem: Self::Elem); fn pop_back(&mut self) -> Option<Self::Elem>; } pub fn is_empty<T: Deque>(q: &T) -> bool { Deque::i...
true
c761009c0505658f4f9f80b9b9433d3f728c19e1
Rust
aleafo/billing_rust
/src/cli/run_server/wait_for_shutdown.rs
UTF-8
1,272
2.609375
3
[ "MIT" ]
permissive
#[cfg(unix)] use signal::unix::{self, SignalKind}; #[cfg(unix)] use std::io; use tokio::select; use tokio::signal; use tokio::sync::mpsc::Receiver; /// 等待停止服务器 pub(super) async fn wait_for_shutdown(mut close_receiver: Receiver<u8>) -> i32 { #[cfg(unix)] let exit_signal_future = unix_exit_signal(); #[cfg(no...
true
15a667f97347e025f500b3b4dc4a236b308b435c
Rust
d6y/jubilee
/src/query.rs
UTF-8
327
2.609375
3
[]
no_license
/* extern crate reqwest; use std::error::Error; use reqwest; fn main() -> Result<(), Box<Error>> { let response = reqwest::get("https://google.com")?; let params = [("foo", "bar"), ("baz", "quux")]; let client = reqwest::Client::new(); let res = client.post("http://httpbin.org/post") .form(&params) .send...
true
f47670745417c29f803034873f60c93134f557d5
Rust
sumeet/aoc2020
/day22b/src/main.rs
UTF-8
1,945
3.234375
3
[]
no_license
use itertools::Itertools; use std::collections::{HashSet, VecDeque}; use std::iter::once; fn main() { let mut decks: Vec<VecDeque<usize>> = vec![]; let mut current_deck = VecDeque::new(); for line in INPUT.lines() { if line.starts_with("Player") { continue; } else if line == "" ...
true
56aacc4b2684b0c0851972369ff86d10683caeff
Rust
mpiannucci/buoyfinder-v3
/core/src/data/swell.rs
UTF-8
1,526
3.234375
3
[]
no_license
use crate::data::dimensional_data::DimensionalData; use crate::data::units::{Units, Measurement, Direction, UnitConvertible}; use std::fmt; #[derive(Clone)] pub struct Swell { wave_height: DimensionalData<f64>, period: DimensionalData<f64>, direction: DimensionalData<Direction>, } impl Swell { pub fn ...
true
6e8ae88910d81ca716ea71502c626c58330e38fc
Rust
alebeck/yocto-rust
/src/util.rs
UTF-8
1,353
2.75
3
[]
no_license
// // (c) 2019 Alexander Becker // Released under the MIT license. // use std::io::prelude::*; use std::net::TcpStream; use std::{result, str}; use crate::error::{StorageError, ParseError}; type Result<T> = result::Result<T, Box<std::error::Error>>; pub const HEARTBEAT: &str = "HEARTBEAT"; pub const GET: &str = "GET...
true
42cb21d08641fe4c7de26e703050e79ef08ea12f
Rust
Volland/steel
/steel/src/rvals.rs
UTF-8
30,460
2.71875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ core::instructions::DenseInstruction, gc::Gc, rerrs::{ErrorKind, SteelErr}, steel_vm::vm::Continuation, values::port::SteelPort, values::structs::SteelStruct, values::{ contracts::{ContractType, ContractedFunction}, lazy_stream::LazyStream, }, }; use std::{ ...
true
7c3e46a2a9a379517ca3ef28a2885e9228891772
Rust
dieface/aleo-setup-integration-test
/src/reporting.rs
UTF-8
5,183
2.859375
3
[]
no_license
//! Utilities for better error reporting and tracing/logging. use std::{ fs::{File, OpenOptions}, io::Write, path::Path, sync::{Arc, Mutex}, }; use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::{ prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter...
true
48de8846aa3535fcea1348ea54bac5825fcdf3aa
Rust
skillzaa/learingRust
/src/durationBetweenTwoTimePoints.rs
UTF-8
305
2.90625
3
[]
no_license
use std::time::SystemTime; fn main() { let sys_time = SystemTime::now(); // println!("{:?}",sys_time.tv_sec); let new_sys_time = SystemTime::now(); let difference = new_sys_time.duration_since(sys_time) .expect("Clock may have gone backwards"); println!("{:?}", difference); }
true
cceae8ff7c40571ef00f1170d11c9ec599a922a9
Rust
micouy/pisak
/src/main.rs
UTF-8
1,438
2.546875
3
[]
no_license
// std use std::{ fs, borrow::Cow, io::{self, BufRead, BufReader}, }; // external use termion::{raw::IntoRawMode, screen::AlternateScreen}; use tui::{ backend::TermionBackend, layout::{Layout, Constraint, Alignment, Rect}, style::{Color, Style}, terminal::Terminal, buffer::Buffer, w...
true
ffc8443aef36ae4ae0c7a098a876cf12220158f0
Rust
pfesenmeier/secret_sauce
/src/bin/make_flavor.rs
UTF-8
689
2.53125
3
[]
no_license
extern crate diesel; use std::io::{stdin, Read}; fn main() { let connection = secret_sauce::establish_connection(); println!("What is the name of your new flavor?"); let mut name = String::new(); stdin().read_line(&mut name).unwrap(); let name = name.trim(); println!("\nOk! Let's write {} (P...
true
a91286c3b4c613ac10f603a6612d2dd6be7a2477
Rust
novito/rust-hello-world
/src/temperature_conversor.rs
UTF-8
569
3.796875
4
[]
no_license
use std::io; fn main() { println!("Welcome to the temperature conversor program"); println!("If you want to convert from Celcius to Fahrenheit, press C - If you want to convert from Fahrenheit to Celcius, press F"); let mut option = String::new(); io::stdin() .read_line(&mut option); let...
true
475c14289644e29ca7857bfd3101e5cb15aa62ae
Rust
ccoder64/ntf
/src/backends/shell.rs
UTF-8
680
2.984375
3
[ "MIT" ]
permissive
use super::Backend; use log::debug; use serde::Deserialize; use std::process::Command; #[derive(Debug, Deserialize)] pub struct Shell { command: String, } impl Backend for Shell { fn send_message(&self, title: &str, message: &str) -> Result<String, String> { debug!("execute command sh -c {}", self.com...
true
cbee9a3dc44b9b13c1ad121b369800d502b5e8c5
Rust
CuriouslyCurious/gw2api
/src/v1/skin_details.rs
UTF-8
1,778
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use serde::Deserialize; use crate::client::Client; use crate::error::ApiError; use crate::utils::Race; const ENDPOINT_URL: &str = "/v1/skin_details"; /// Struct containing information about a specified skin. #[derive(Debug, Deserialize, PartialEq)] pub struct Skin { /// id of the skin. #[serde(rename = "skin...
true
58ad84ad9b584bf06513f837d8e91c11640f6234
Rust
nabijaczleweli/bloguen
/tests/error/display/mod.rs
UTF-8
1,318
2.59375
3
[ "MIT" ]
permissive
mod io; use bloguen::Error; #[test] fn parse() { assert_eq!(Error::Parse { tp: "datetime", wher: "post descriptor".into(), more: "not RFC3339".into(), } .to_string(), "Failed to parse datetim...
true
a23b9069c5f8a11e2d64f056f98d1f672885c646
Rust
bsaintjo/compbio
/src/trie.rs
UTF-8
2,495
3.109375
3
[]
no_license
use itertools::unfold; use petgraph::dot::Dot; use petgraph::prelude::*; #[derive(Default)] pub struct Trie { root: NodeIndex, tree: Graph<(), u8>, } impl Trie { pub fn new() -> Self { let mut tree = Graph::new(); let root = tree.add_node(()); Trie { root, tree } } pub fn ...
true
754ab7e7a1cd7f736996e371a5b08b0fbc769700
Rust
hoangpq/process-viewer
/src/graph.rs
UTF-8
10,822
2.703125
3
[ "MIT" ]
permissive
use cairo; use gtk::{self, BoxExt, ContainerExt, DrawingArea, ScrolledWindowExt, StateFlags, WidgetExt}; use std::cell::RefCell; use gdk::{self, WindowExt}; use std::rc::Rc; use std::time::Instant; use color::Color; use utils::RotateVec; const LEFT_WIDTH: f64 = 31.; pub struct Graph { elapsed: Instant, colo...
true
925a5f1740eb2520e34f80b4a5f813113709664b
Rust
reyk/web-sys-query
/derive/src/lib.rs
UTF-8
4,499
2.578125
3
[ "ISC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Helper macros for `web-sys-query` use convert_case::{Case, Casing}; use proc_macro2::{Ident, Span, TokenStream}; use quote::quote; use syn::{parse_macro_input, ItemEnum}; #[proc_macro_derive(OnEvent, attributes(unimplemented))] pub fn derive_on_event(item: proc_macro::TokenStream) -> proc_macro::TokenStream { ...
true
0753f40718b31e60c2b0c9e7ab0dbd9402e6ede1
Rust
gmoller/Sorcery
/src/units.rs
UTF-8
3,981
2.53125
3
[]
no_license
use std::collections; use bevy::prelude::*; use crate::constants::{BACKDROP_GREEN, BACKDROP_INDIGO, BACKDROP_RED, BACKLIGHT, HALF, HEX_SIZE, LAYOUT_SIZE, SCALE, UNIT_FRAME_INACTIVE, UNIT_HP_FILL}; use crate::create_bundles::create_sprite_bundle; use crate::config::units::UnitTypes; use crate::components::{OwnedByFacti...
true
fa1aed18b40929230775242ace54b1d36677c740
Rust
vaultinc/vault.finance
/pallets/market/src/math.rs
UTF-8
1,012
3.140625
3
[ "Unlicense" ]
permissive
use crate::Trait; pub fn sqrt<T: Trait>(y: <T as asset::Trait>::Balance) -> <T as asset::Trait>::Balance { if y > <T as asset::Trait>::Balance::from(3) { let mut z = y; let mut x: <T as asset::Trait>::Balance = y / <T as asset::Trait>::Balance::from(2); x += <T as asset::Trait>::Balance::fro...
true
4fd837de1b5a294d3af05939a34b68251afd5fea
Rust
Delthii/AoC2020
/src/day2.rs
UTF-8
1,352
3.328125
3
[]
no_license
use std::fs::File; use std::io::{prelude::*, BufReader}; pub fn solution(){ let reader = BufReader::new(File::open("./res/day2.in").expect("Couldn't open file")); let rows: Vec<String> = reader.lines().map(|l| l.expect("Expected line")).collect(); let valid = rows .iter().map(|r| parse(r)) ...
true
df2f33a0c867c031037486d91fd198a896ddd508
Rust
gustavderdrache/tiger
/tiger_syntax/src/expression.rs
UTF-8
2,690
2.5625
3
[]
no_license
use indexmap::IndexMap; use crate::pos::Spanned; #[derive(Debug, Clone)] pub enum TypeData { Identifier(String), Record(IndexMap<String, String>), Array(String), } pub type Type = Spanned<TypeData>; #[derive(Debug, Clone)] pub struct TypeDeclData { pub name: String, pub decl: Type, } pub type T...
true
b91a6fd1370ad59f1a838296a4e81b0cb20a8e00
Rust
servo/green-rs
/libgreen/src/basic.rs
UTF-8
7,095
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
true
db6c9b866b75def5a311f05dba1b98a5c04b5760
Rust
dragonmaus/realpath.rs
/src/bin/fixpaths.rs
UTF-8
1,698
2.6875
3
[ "BSD-3-Clause-Clear" ]
permissive
use getopt::Opt; use realpath::realpaths; use std::{env, io}; program::main!("fixpaths"); fn print_usage(program_name: &str) { println!("Usage: {} [-h] [-e VAR] [string ...]", program_name); println!(" -e VAR operate on the value of environment variable VAR"); println!(); println!(" -h display...
true
9cd5669cebda16833be42d0eedc6e1f0f433449b
Rust
johalun/sysctl-rs
/src/lib.rs
UTF-8
2,304
2.6875
3
[ "MIT" ]
permissive
// lib.rs //! A simplified interface to the `sysctl` system call. //! //! # Example: Get value //! ``` //! # use sysctl::Sysctl; //! #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] //! const CTLNAME: &str = "kern.ostype"; //! #[cfg(any(target_os = "linux", target_os = "android"))] //! const ...
true
064b89d44d3c59c516ac4cb89530b429f2914282
Rust
cksac/fake-rs
/fake/examples/primitives.rs
UTF-8
1,259
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
use fake::{Fake, Faker}; use rand::distributions; use rand::rngs::StdRng; use rand::SeedableRng; fn main() { // generate random u8 println!("u8 ({}) in [MIN, MAX)", Faker.fake::<u8>()); // generate random u8 using range println!("u8 ({}) in [3,7)", (3..7).fake::<u8>()); println!("u8 ({}) in [3,7]"...
true
1c6d0646b1ff67fa38a5465ab631a8830a879e25
Rust
fizyk20/slackbot
/src/main.rs
UTF-8
6,363
2.6875
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate slack; extern crate slack_api; extern crate regex; extern crate timer; extern crate chrono; extern crate dictionary; extern crate rand; mod settings; mod plugin; mod plugins; mod logger; use logger::Logger; use plugin::Plugin; use plugins::*; use settings::SETTINGS;...
true
1247823f7a2c1b185a3035682bf7ba5a4c4399c7
Rust
White-Green/Portfolio
/src/app.rs
UTF-8
3,531
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
use yew::prelude::*; use yew_router::{prelude::*, route::Route}; use crate::components::{footer::footer, nav::Nav}; use crate::routes::{AppRoute, home::Home, license::License, links::Links, profile::Profile, qualifications::Qualifications, works::Works}; /// Root component pub(crate) struct App { current_...
true
6da5f0563f7f32bb5673b7dea44ccd949b5149ad
Rust
edgex004/rust-hdl
/rust-hdl-synth/src/lib.rs
UTF-8
3,381
2.53125
3
[ "MIT" ]
permissive
use rust_hdl_core::prelude::*; use std::env::temp_dir; use std::fs::{create_dir, remove_dir_all, File}; use std::io::{Error, Write}; use std::process::Command; #[derive(Debug)] pub enum SynthError { SynthesisFailed { stdout: String, stderr: String }, LatchingWriteToSignal(Vec<String>), ImplicitlyDeclared(V...
true
b5f275d647169b01fc59d7bbf6f020cb9f4de756
Rust
DreamLarva/learn-rust
/src/macro_book3.rs
UTF-8
1,434
3.1875
3
[]
no_license
pub fn main() { // 调试 // rustc 提供了调试宏. // 其中最有用的就是 trace_macros!. // 他会只是编译器,在每一个宏调用被展开将其转印出来 macro_rules! each_tt { () => {}; ($tt:tt $($rest:tt)*) => { println!("{}",stringify!($tt)); each_tt!($($rest)*); }; } // each_tt!(fo...
true
d99b102643c575242cbcd7e4ecd75d408dd14280
Rust
lbovet/iced
/core/src/menu.rs
UTF-8
4,016
3.96875
4
[ "MIT" ]
permissive
//! Build menus for your application. use crate::keyboard::Hotkey; /// Menu representation. /// /// This can be used by `shell` implementations to create a menu. #[derive(Debug, Clone)] pub struct Menu<Message> { entries: Vec<Entry<Message>>, } impl<Message> PartialEq for Menu<Message> { fn eq(&self, other: &...
true
bf6371e9654eb1f15e2a065d4fb39a1633f930dc
Rust
coka/moxie
/topo/src/lib.rs
UTF-8
17,252
3.234375
3
[ "MIT", "Apache-2.0" ]
permissive
#![deny(missing_docs, intra_doc_link_resolution_failure)] //! Topological functions execute within a context unique to the path in the runtime call //! graph of other topological functions preceding the current activation record. //! //! Defining a topological function results in a macro definition for binding th...
true
79f40f01eebc9db111319cd1de2b5bf1c03ea319
Rust
mal2017/frip
/src/frip.rs
UTF-8
2,401
2.640625
3
[ "MIT" ]
permissive
use super::genome_tree::*; use rust_htslib::bam; use rust_htslib::bam::Read; use rust_htslib::bam::HeaderView; use std::collections::HashMap; use rust_htslib::bam::record::*; use bio::data_structures::interval_tree::IntervalTree; use core::ops::Range; use std::str; pub fn rip(reads_file: &str, regions_file: &str, p: u...
true
1616aa7ec06c25135e61e12b9f78808325b6bdec
Rust
autondesigner/unart
/src/torus.rs
UTF-8
5,390
3.578125
4
[ "MIT" ]
permissive
use crate::address::*; use crate::address_book::*; use crate::buildable::*; use crate::direction::*; pub struct Torus<T: Buildable> { pub height: usize, pub width: usize, pub cells: Vec<T>, pub books: Vec<AddressBook>, } impl<T: Buildable> Torus<T> { pub fn new(width: usize, height: usize) -> Toru...
true
d72b47c5b14822a80f55fdfe6a60e8ca6e325ca9
Rust
mtso/ksuid
/cli/src/main.rs
UTF-8
2,001
2.953125
3
[ "MIT" ]
permissive
#[macro_use] extern crate serde_derive; extern crate docopt; extern crate ksuid; extern crate rand; extern crate time; use std::io::{self, Write}; use std::process::exit; use ksuid::Ksuid; use rand::Rng; const USAGE: &str = " ksuid Usage: ksuid [--count=<n>] ksuid inspect <uids>... Options: -n=<n>, --...
true
ca10e2c521b3da3d3951bf35d00e760c1d72764f
Rust
tzfx/foodsbot
/src/main.rs
UTF-8
3,207
2.921875
3
[]
no_license
use std::{env, process, error}; use serde::{Deserialize, Serialize}; use chrono::prelude::*; use slack; use slack::{Event, RtmClient}; #[allow(non_snake_case)] #[derive(Serialize, Deserialize, Debug)] struct Delivery { RestaurantName: String, Cutoff: String, Dropoff: String } #[allow(non_snake_case)] #[de...
true
27a753960f9fee48fd898424a0a8be5158889aa7
Rust
dotboris/alt
/src/scan_cmd.rs
UTF-8
2,025
2.734375
3
[ "MIT" ]
permissive
use crate::command_version::CommandVersion; use crate::environment::load_command_version_registry; use crate::scan; use crate::shim; use anyhow::Context; use dialoguer::MultiSelect; use std::env; use std::process; fn prompt_versions(versions: &[CommandVersion]) -> Vec<usize> { let items: Vec<_> = versions ...
true
40fb6589e4a1b77bf06967e05f7e0be8917bea28
Rust
brndnmtthws/cracking-the-coding-interview-rust
/src/bin/c08p03.rs
UTF-8
751
3.46875
3
[ "Unlicense" ]
permissive
fn find_magic_index(arr: &[i64]) -> Option<usize> { let middle_index = arr.len() / 2; let middle_value = arr[middle_index]; if (middle_index as i64) == middle_value { Some(middle_index) } else if (middle_index as i64) < middle_value && arr.len() >= 2 { // search left find_magic_i...
true
87b7b1aaa8fc068cea9ea65551f84fd3c9d8b803
Rust
illumos/rust-fmamsg
/src/bits.rs
UTF-8
1,652
3.3125
3
[ "Apache-2.0" ]
permissive
/* * Copyright 2020 Oxide Computer Company */ #[derive(Debug, Clone)] pub struct Bits { value: u128, bitcount: usize, } pub fn mask(count: usize) -> u128 { let mut mask = 0; for i in 0..count { mask |= 1 << i; } mask } impl Bits { pub fn new() -> Self { Bits { ...
true
e3141bb5e8cf7765b1c10f3b58e19083d75ce3ee
Rust
tillrohrmann/rust-challenges
/aoc_2019_8/src/lib.rs
UTF-8
3,569
3.484375
3
[ "Apache-2.0" ]
permissive
use std::{fs, io}; pub struct Image { width: u32, height: u32, layers: Vec<Vec<u32>>, } impl Image { pub fn load_from_file(width: u32, height: u32, filename: &str) -> io::Result<Image> { let content = fs::read_to_string(filename)?; Image::load_from_str(width, height, &content) } ...
true
580693e995895220e94013292fdf7227cfc67457
Rust
jlek/gedcom-parser
/src/gedcom_data_format/error.rs
UTF-8
1,411
3.0625
3
[]
no_license
use serde::{de, ser}; use std::fmt::{Display, Formatter}; pub type Result<T> = std::result::Result<T, Error>; #[derive(Clone, Debug, PartialEq)] pub enum Error { Message(String), InvalidGedcomLine, ExpectedGedcomLineWithValue, ExpectedMap, ExpectedMapEnd, TrailingCharacters, } impl ser::Error for Error {...
true
d6fff0aeab87836bc3fa822a10fb026c57ef377a
Rust
danvk/aoc2020
/src/bin/day19.rs
UTF-8
7,809
3.328125
3
[]
no_license
#[macro_use] extern crate lazy_static; use regex::Regex; use std::collections::{HashMap, HashSet}; use std::env; use itertools::Itertools; #[derive(Debug)] enum Rule { Literal(char), Pattern(Vec<Vec<i32>>), } impl Rule { /// Try to match the start of txt, returning the remainder. fn match_str<'a>(&sel...
true
fc79904f55795139bb7b854d42cb5b293859447d
Rust
carlomilanesi/rs-measures
/src/measure1d.rs
UTF-8
12,191
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[macro_export] macro_rules! define_measure1d { {} => { use rs_measures::{angle::{Angle, Radian}, traits::{ArithmeticOps, LossyFrom, MeasurementUnit, AngleMeasurementUnit, VectorMeasurementUnit}}; use core::ops::{Neg, Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; use std::...
true