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
121b5c92be57376863c8a320828367a0c0d8b9e1
Rust
Holo-Host/holo-auth
/client/src/validation.rs
UTF-8
2,603
2.53125
3
[ "Apache-2.0" ]
permissive
use super::AuthError; use failure::*; use holochain_types::dna::AgentPubKey; use std::env; use std::fs; use tracing::*; fn device_bundle_password() -> Option<String> { match env::var("DEVICE_SEED_DEFAULT_PASSWORD") { Ok(pass) => Some(pass), _ => None, } } // Read the hp-* file and get the devi...
true
7f896da7b6cfd05fead95baceeecc9a1e6001973
Rust
lupyuen/sx126x-rs-nuttx
/src/op/status.rs
UTF-8
1,618
3.234375
3
[]
no_license
#[derive(Copy, Clone)] pub struct Status { inner: u8, } impl core::fmt::Debug for Status { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let chip_mode = self.chip_mode(); let command_status = self.command_status(); write!( f, "Status {{in...
true
5e9351aaae79cd82b4ce6ac80527bb88c5b3efd3
Rust
chongyi/inspirer-actix-ext-support
/inspirer-actix-modules/database-sqlx/src/statement/pagination.rs
UTF-8
2,143
3.140625
3
[]
no_license
const DEFAULT_PER_PAGE: u64 = 20; const DEFAULT_PAGE: u64 = 1; #[derive(Serialize, Deserialize, Copy, Clone, Debug)] pub struct Paginate { pub page: u64, pub per_page: u64, } impl Default for Paginate { fn default() -> Self { Paginate::new(DEFAULT_PAGE, DEFAULT_PER_PAGE) } } impl Paginate { ...
true
08f19dce4bc1fe70253c929d599b010152fb8712
Rust
Luni-4/iced_aw
/src/native/cupertino/cupertino_colours.rs
UTF-8
1,854
3.203125
3
[ "MIT" ]
permissive
use iced_native::Color; /// <https://flutter.github.io/assets-for-api-docs/assets/cupertino/cupertino_system_colors_1.png> /// <https://flutter.github.io/assets-for-api-docs/assets/cupertino/cupertino_system_colors_2.png> /// <https://flutter.github.io/assets-for-api-docs/assets/cupertino/cupertino_system_colors_3.png...
true
bf179ae142077d075a8b01465a8cad0057ef8e75
Rust
suclogger/leetcode-rust
/chapter_11/array/max-chunks-to-make-sorted/src/main.rs
UTF-8
796
3.46875
3
[]
no_license
fn main() { assert_eq!(max_chunks_to_sorted(vec![4,3,2,1,0]), 1); assert_eq!(max_chunks_to_sorted(vec![1,0,2,3,4]), 4); } /** 思路:可以往前缀和上思考 比如: [2 1] 3 3 4 [1 2] 3 3 4 -- 有序结果数组 那原数组与有序数组前缀和相等的连续元素,里面的元素肯定跟有序数组的元素是一样的(虽然顺序不一样)#同分异构# **/ pub fn max_chunks_to_sorted(arr: Vec<i32>) -> i32 { let mut su...
true
74b376f3f5c6a8cfb8302a8740133a96e238c426
Rust
btabram/AdventOfCode2018
/21/src/main.rs
UTF-8
6,781
3.34375
3
[]
no_license
use std::collections::HashSet; type ErrorHolder = Box<std::error::Error>; fn main() -> Result<(), ErrorHolder> { // *Part 1* logic (calculate solution later on with part 2) // // Only command 28 makes use of the [0], since we can only effect // [0] the program up until the point where command 28 runs ...
true
e64fb7574a676038752d040664f7e4b0be8a63fa
Rust
llogiq/funzzy
/tests/main.rs
UTF-8
836
2.609375
3
[ "MIT" ]
permissive
extern crate funzzy; mod cli; #[warn(unused_imports)] use std::io::prelude::*; use std::fs::{ File, remove_file }; #[test] fn it_returns_some_command() { let mut args = funzzy::cli::Args::new(); args.cmd_init = true; assert!(funzzy::cli::command(&args).is_some()) } #[test] fn it_returns_no_command() { le...
true
730bf7c4615e3fe76c8bc886906093d2396e7757
Rust
creativeJoe007/my_rusty
/struct_/src/main.rs
UTF-8
2,136
4.1875
4
[]
no_license
/* Struct: Are like tuples but they are more flexible and can be sorted using field names It's just like object in OOP languages */ struct User { username: String, email: String, sign_in_count: u64, active: bool } /* Struct ownership, we have been clearing string variables as String...
true
0a9aad64b9c9da2be0217b08d596eb6e77c93f50
Rust
johnathan79717/rust-finite-field
/src/field/extension.rs
UTF-8
657
2.90625
3
[]
no_license
//use std::marker::PhantomData; use std::default::Default; use std::ops::*; use std::cmp::max; pub struct Poly<K> { coeff: Vec<K>, } impl<K> AddAssign for Poly<K> where K: Default + Clone + AddAssign { fn add_assign(&mut self, mut rhs: Self) { let n = max(self.coeff.len(), rhs.coeff.len()); se...
true
596956756a908da3fed49545624b2aacf717e5e1
Rust
neil-b/gbc-emu
/src/registers.rs
UTF-8
1,885
3.15625
3
[]
no_license
fn join_u8_to_u16(high: u8, low: u8) -> u16 { (high as u16) << 8 | (low as u16) } fn split_u16_to_u8(val: u16) -> (u8, u8) { ( ((val & 0xFF00) >> 8) as u8, (val & 0x00FF) as u8, ) } pub struct Registers { // http://bgb.bircd.org/pandocs.htm#cpuregistersandflags pub a: u8, pub f...
true
9d07a2f7800fafe2eae73108be55600f75536c2a
Rust
ocstl/project_euler
/src/bin/problem26.rs
UTF-8
809
3.375
3
[]
no_license
/* With a reduced fraction m/n, the period of length t begins after s terms, where: 10^s == 10^(s+t) mod n. */ fn period_length(x: usize) -> usize { /* Products of the powers of 2 and 5 do not have a repeating cycle. */ let mut x = x; while x % 2 == 0 { x /= 2; } while x % 5 == 0 { ...
true
8c603ca791bc511c7008464cbaa2bb7444bd3cc8
Rust
HallerPatrick/civa
/src/builtins/error.rs
UTF-8
482
2.921875
3
[ "MIT" ]
permissive
use std::{fmt, io}; #[derive(Debug)] pub struct BuiltinError { pub kind: String, pub message: String, } impl From<io::Error> for BuiltinError { fn from(error: io::Error) -> Self { BuiltinError { kind: String::from("io"), message: error.to_string(), } } } impl f...
true
6a26e50d1d0ff708376025e3995eb28587ba661a
Rust
imoegirl/rust-by-example
/src/p055_trait_drop.rs
UTF-8
622
3.296875
3
[]
no_license
struct Droppable { name: &'static str, } impl Drop for Droppable { fn drop(&mut self) { println!("> Dropping {}", self.name); } } pub fn run(){ println!("p055_trait_drop >>>>>>>>"); let _a = Droppable{name: "a"}; { let _b = Droppable{name: "b"}; { let _c = D...
true
be276b672e639e7ba62353aa3a8a5b2d699ab8f7
Rust
MaulingMonkey/yet-another-bad-wasm-interpreter
/src/wasm/types.rs
UTF-8
7,583
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! [Types](https://webassembly.github.io/spec/core/binary/types.html) use crate::*; use std::fmt::{self, Debug, Display, Formatter}; /// [Number types](https://webassembly.github.io/spec/core/binary/types.html#number-types) #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(u8)] pub enum NumType ...
true
749bfd22e8af771bdf0ed9a2855c1ba6c86c11cd
Rust
jacobsee/nand-logic
/src/components/gates/not.rs
UTF-8
1,243
2.96875
3
[]
no_license
use crate::components::wiring; use crate::components::NANDGate; pub struct NOTGate { pub input: wiring::Wire, pub output: wiring::Wire, nand: NANDGate, } impl Default for NOTGate { fn default() -> Self { NOTGate { input: wiring::Wire::default(), output: wiring::Wire::de...
true
ce85f7d12799532fb11599bdcbd8af65ec6ba4bb
Rust
PtrMan/20NAR1
/src/NarSentence.rs
UTF-8
3,733
2.859375
3
[ "MIT" ]
permissive
use std::sync::{Arc}; use parking_lot::RwLock; use crate::Term::Term; use crate::Tv; use crate::Term::convTermToStr; use crate::NarStamp::*; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum EnumPunctation { JUGEMENT, // . QUESTION, // ? GOAL, // ! } // abstraction for evidence // we need it because...
true
47cf6b7901cb0bcfaefb86a7f6d044e6c6f84d12
Rust
HadrienG2/coursera-crypto
/src/lib.rs
UTF-8
1,562
3.140625
3
[]
no_license
//! This is just a bunch of tools I built to solve the exercises of Coursera's //! crypto MOOC. It does not take the required precautions to be used as a //! serious crypto tool (e.g. clearing memory before returning it, making sure //! that all operations on secret data take constant time), and should therefore //! no...
true
945b931c1dbb2f8c34b4c85d883c5f8e49530b1c
Rust
gb-archive/scimitar
/src/interrupt.rs
UTF-8
546
3.140625
3
[ "Apache-2.0", "MIT" ]
permissive
pub enum Interrupt { VBlank, Stat, Timer, SerialIO, Gamepad } #[derive(Default)] pub struct Irq { iflags: u8, } impl Irq { pub fn raise_interrupt(&mut self, int: Interrupt) { self.iflags |= match int { Interrupt::VBlank => 0x01, Interrupt::Stat => 0x02, ...
true
48931fdb71a6d85b5dcc7cb0bbf02552a35ed1f0
Rust
fhyfhy17/GameServer_Rust
/net_test/src/test_async.rs
UTF-8
1,015
3.8125
4
[]
no_license
use futures::join; pub async fn learn_and_sing() { // 要唱歌必须得先学会歌曲. // 我们这里使用 `.await` 而不是 `block_on` 来 // 防止线程阻塞, 这样也可以同时跳舞. let song = learn_song().await; sing_song(song).await; } pub async fn learn_song()->String{ println!("learn_song"); std::thread::park(); "learn_song".to_owned() }...
true
c230cf096021cf11185c82cac760da236b91eab4
Rust
panzertime/alexctf
/bot/src/main.rs
UTF-8
1,399
3.203125
3
[ "Apache-2.0" ]
permissive
extern crate num; use num::bigint::*; use num::Zero; use num::Integer; use std::io::Read; use std::io::prelude::*; use std::io::Error; use std::net::TcpStream; fn main() { work().unwrap(); } fn work() -> Result<(), Error> { let mut stream = TcpStream::connect("195.154.53.62:1337").unwrap(); let mut buf = [0; 150...
true
aa5a40474a52794d37c75cbcb72e99645da0cce9
Rust
duncanrhamill/scos
/src/vga_buffer.rs
UTF-8
9,279
3.3125
3
[]
no_license
// --------------------------------------------------------------------------- // USE STATEMENTS // --------------------------------------------------------------------------- use volatile::Volatile; use core::fmt; use lazy_static::lazy_static; use spin::Mutex; use core::fmt::Write; // Serial print imports for testin...
true
b50d92bea64159d5a1d4e4121666aa7bd72bf044
Rust
tkygtr6/tutorials
/Rust-practice/ITP1_7_B.rs
UTF-8
712
2.921875
3
[]
no_license
fn main() { loop { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let nums = line .split_whitespace() .map(|c| c.parse::<u32>().unwrap()) .collect::<Vec<_>>(); let n = nums[0]; let sum = nums[1]; if ...
true
16028ce22e8da6f0035143a856ea934d58cb97b4
Rust
andmer/stepanov-conversations-course
/languages/rust/sort64.rs
UTF-8
1,120
2.84375
3
[]
no_license
extern crate time; use std::rand::Rng; use std::slice::MutableCloneableVector; mod quicksort64; fn time_sort(data: &[u64], buffer: &mut [u64], size: uint) -> u64 { let mut first = 0u; let start_time = time::precise_time_ns(); while first <= data.len() - size { buffer.mut_slice(0, size).copy_from(data.slice(...
true
84a0a4ce0158351bfd920e5313645b39cf504361
Rust
zenixls2/ap-kcp
/src/segment.rs
UTF-8
3,025
3.09375
3
[ "MIT" ]
permissive
use bytes::{Buf, BufMut, Bytes}; use crate::error::{KcpError, KcpResult}; pub(crate) const HEADER_SIZE: usize = 2 + 1 + 2 + 4 + 4 + 4 + 2; pub(crate) const CMD_PUSH: u8 = 1; pub(crate) const CMD_ACK: u8 = 2; pub(crate) const CMD_PING: u8 = 3; #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct KcpSegm...
true
0dfa3a5767193602042229c471c122d5bea17983
Rust
andrewpedia/cashbox
/bc/chain/btc/murmel/src/kit.rs
UTF-8
1,589
3
3
[ "Apache-2.0" ]
permissive
#![allow(dead_code)] use bitcoin::consensus::encode::Error; use bitcoin::Transaction; use bitcoin_hashes::hex::ToHex; use bitcoin_hashes::Hash; use std::fmt::Write; pub fn hash160(str: &str) -> String { let decode: Vec<u8> = bitcoin_hashes::hex::FromHex::from_hex(str).expect("Invalid public key"); let hash = b...
true
beddd059155e9c79d4c6b16b6bf47b3ddc9604d4
Rust
baronleonardo/to-do-list
/src/db.rs
UTF-8
543
3
3
[ "MIT" ]
permissive
pub mod db { use std::fs::File; use std::io::Read; use std::io::Write; use std::path::Path; pub fn read(file_path: &str) -> String { let mut buf = String::new(); if Path::new(file_path).exists() { let mut file = File::open(&file_path).unwrap(); file.read_to_...
true
a3d907703c07b60e3e34ec4e73f0446ba30b8bc1
Rust
svenstaro/dfrs
/src/args.rs
UTF-8
2,988
2.734375
3
[ "MIT" ]
permissive
use structopt::StructOpt; use structopt::clap::{AppSettings, Shell}; use std::io::stdout; use strum_macros::EnumString; use std::path::PathBuf; use anyhow::Result; #[derive(Debug, StructOpt)] #[structopt(about="Display file system space usage using graphs and colors.", global_settings = &[AppSettings::ColoredHelp, A...
true
986b9d520b40b1ec530a2938896be2beb3a156f5
Rust
lukexor/pix-engine
/src/color.rs
UTF-8
27,937
3.8125
4
[ "MIT", "Apache-2.0" ]
permissive
//! [Color] functions for drawing. //! //! Each [Color] can be constructed with a [Mode]. The default mode and internal //! representation is [Rgb] with values ranging from `0..=255` for red, green, blue, and alpha //! transparency. [Hsb] and [Hsl] values range from `0.0..=360.0` for hue, `0.0..=100.0` for //! saturati...
true
2d666a875665d7545504816479c17d8783a6bf8e
Rust
jcdavis/aoc2018
/day10/src/main.rs
UTF-8
2,451
3.015625
3
[]
no_license
extern crate regex; use std::collections::HashSet; use std::env; use std::fs::File; use std::io::{BufRead, BufReader, Result}; use regex::Regex; fn main() { let args: Vec<String> = env::args().collect(); let f = File::open(&args[1]).unwrap(); let br = BufReader::new(f); let re = Regex::new(r"position...
true
3b76ad5b60a6fd6731888c26af4fb67a5bb0639f
Rust
moshg/rust-std-ja
/src/test/run-pass/func-arg-ref-pattern.rs
UTF-8
1,049
2.625
3
[ "MIT", "Apache-2.0", "BSD-3-Clause", "NCSA", "LicenseRef-scancode-other-permissive", "BSD-2-Clause" ]
permissive
// Copyright 2014 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
120bc61cc32101c5d878244521e4888bace3019a
Rust
jyn514/docs.rs
/src/utils/github_updater.rs
UTF-8
7,059
2.671875
3
[ "MIT" ]
permissive
use crate::error::Result; use crate::{db::Pool, Config}; use chrono::{DateTime, Utc}; use failure::err_msg; use log::{debug, warn}; use postgres::Client; use regex::Regex; use reqwest::{ blocking::Client as HttpClient, header::{HeaderMap, HeaderValue, ACCEPT, AUTHORIZATION, USER_AGENT}, }; use serde::Deserializ...
true
9b4053741ee5b6c2729b1a78a9901c5d609b020c
Rust
nisarhassan12/materialize
/src/expr/src/scalar/func/impls/interval.rs
UTF-8
2,500
2.5625
3
[ "Apache-2.0", "BSD-2-Clause", "CC0-1.0", "BSD-3-Clause", "MPL-2.0", "0BSD", "PostgreSQL", "GPL-1.0-or-later", "GPL-2.0-only", "MIT", "BUSL-1.1" ]
permissive
// Copyright Materialize, Inc. and contributors. All rights reserved. // // Use of this software is governed by the Business Source License // included in the LICENSE file. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by ...
true
f2664622028a03c1298c46f11169977444d3e572
Rust
houqp/axum
/src/routing/future.rs
UTF-8
3,781
2.640625
3
[ "MIT" ]
permissive
//! Future types. use crate::{ body::BoxBody, routing::{FromEmptyRouter, UriStack}, }; use http::{Request, Response}; use pin_project_lite::pin_project; use std::{ convert::Infallible, future::Future, pin::Pin, task::{Context, Poll}, }; use tower::util::Oneshot; use tower_service::Service; opa...
true
24075d2ec8ebacf6d52a744997be3d374ebec28e
Rust
nushell/nushell
/crates/nu-protocol/src/span.rs
UTF-8
2,375
3.40625
3
[ "MIT" ]
permissive
use miette::SourceSpan; use serde::{Deserialize, Serialize}; /// A spanned area of interest, generic over what kind of thing is of interest #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct Spanned<T> where T: Clone + std::fmt::Debug, { pub item: T, pub span: Span, } /// Spans are ...
true
afa5f80db8f76dfd62752c32a7d72c6e15fbba12
Rust
jlebon/afterburn
/src/providers/openstack/network.rs
UTF-8
3,273
2.59375
3
[ "Apache-2.0" ]
permissive
//! openstack metadata fetcher use std::collections::HashMap; use anyhow::{anyhow, bail, Result}; use openssh_keys::PublicKey; use crate::providers::MetadataProvider; use crate::retry; #[cfg(not(test))] const URL: &str = "http://169.254.169.254/latest/meta-data"; #[derive(Clone, Debug)] pub struct OpenstackProvide...
true
dba761cd02e6380b0ca7ad3ce7b47cd837d5bbf0
Rust
NKcell/leetcode
/60. Permutation Sequence/leetcode60/src/main.rs
UTF-8
666
3.59375
4
[]
no_license
fn main() { println!("Hello, world!"); let s = get_permutation(4, 9); println!("{}", s); } fn get_permutation(n: i32, k: i32) -> String { let mut res = String::from(""); let mut n1 = n; let mut k1 = k; k1 -= 1; let mut tmp: Vec<String> = Vec::new(); for i in 1..n+1{ tmp.push...
true
b249e0efebe5dfdf5a0ac4c91a259c79cd227151
Rust
delta62/aoc2019
/src/day1.rs
UTF-8
1,475
3.34375
3
[]
no_license
#[aoc_generator(day1)] pub fn input_generator(input: &str) -> Vec<i32> { input .lines() .map(|line| line.parse().expect("Unable to parse integer from input")) .collect() } #[aoc(day1, part1)] pub fn solve_part1(input: &[i32]) -> i32 { input.iter().fold(0, |acc, mass| acc + mass / 3 - 2)...
true
8bec2a25452b556e3609fc3d8e526cc7f8f78f26
Rust
hnen/rust-to-unity
/rust/src/my_rust_struct.rs
UTF-8
697
3.015625
3
[ "Unlicense" ]
permissive
use std::mem; #[repr(C)] pub struct MyRustStruct { i0: i32, i1: i32, f0: f32, } #[no_mangle] pub extern "C" fn my_rust_struct_new() -> *mut MyRustStruct { let my_rust_struct = MyRustStruct { i0: 1, i1: 2, f0: 1.0, }; unsafe { mem::transmute(Box::new(my_rust_struct)) } }...
true
0b5e4ea7f243a8a93bbe970602244b2785753582
Rust
dtynn/learning
/leetcode-rs/p0207_course_schedule/src/lib.rs
UTF-8
1,543
3.171875
3
[]
no_license
pub struct Solution {} use std::collections::{BTreeMap, BTreeSet}; impl Solution { pub fn can_finish(num_courses: i32, prerequisites: Vec<Vec<i32>>) -> bool { let mut pres: BTreeMap<i32, Vec<i32>> = BTreeMap::new(); for p in prerequisites.iter() { pres.entry(p[0]) .and_...
true
3f77e726b5589693446eef74bd37b75b0913172d
Rust
GaloisInc/swanky
/inferno/src/tests.rs
UTF-8
4,089
2.59375
3
[ "MIT" ]
permissive
use crate::Proof; use proptest::prelude::*; use scuttlebutt::field::{F64b, FiniteField, F2}; use scuttlebutt::ring::FiniteRing; use scuttlebutt::{AesRng, Block}; use simple_arith_circuit::Circuit; use std::path::PathBuf; // The number of parties in the MPC const N: usize = 16; // The compression factor const K: usize ...
true
30df4c3a881ac2aa5d9c9ee7c5ab35e585e9b8f4
Rust
arnabanimesh/amicable_num_bench
/rsloop.rs
UTF-8
438
3.234375
3
[ "Apache-2.0" ]
permissive
fn d(n: i32) -> i32 { let mut result: i32 = 1; for m in 2 .. (n / 2 + 1) { if (n % m) == 0 { result += m; } } result } fn amicable(n:i32) -> i32 { let dn=d(n); let ddn=d(dn); if (ddn==n) && (n != dn) { n } else { 0 } } fn main () { le...
true
fe6fa40907ca57d183aca5c9f345bbe96b68f65a
Rust
shurizzle/riglet
/tests/test_loader.rs
UTF-8
1,567
2.640625
3
[ "WTFPL" ]
permissive
#![cfg(test)] use std::{process::Stdio, str}; use riglet::{FIGfont, FIGure}; use run_figlet::RunFiglet; fn chop(s: &str) -> String { let mut s = s.to_string(); if s.ends_with("\r\n") { s.truncate(s.len() - 2); } else if s.ends_with("\n") { s.truncate(s.len() - 1); } s } fn run_t...
true
1e8c403b4cce0ee0d6fbb421651979c772457f6c
Rust
abesto/rktrl
/src/resources/layout.rs
UTF-8
1,382
2.5625
3
[]
no_license
use std::cmp::{max, min}; use std::convert::TryInto; use bracket_lib::prelude::{Point, Rect}; #[derive(Copy, Clone, Debug)] pub struct Layout { pub width: i32, pub height: i32, pub panel_height: i32, } impl Layout { pub fn map(&self) -> Rect { Rect::with_size(0, 0, self.width, self.height - s...
true
d160c3e6d682d7cdb4dbc5e621931f635ab5a7d1
Rust
michaelsmithxyz/advent-of-code-2020
/src/day5.rs
UTF-8
2,370
3.28125
3
[]
no_license
use std::collections::HashSet; const ROW_MAX: u8 = 127; const COL_MAX: u8 = 7; #[derive(Debug)] enum Rows { Single(u8), Range(u8, u8) } impl Rows { fn unwrap(&self) -> u8 { match self { Rows::Single(v) => *v, _ => panic!("Unwrapped range for Row") } } } #[deri...
true
a79ec27fc44f01ae03bbe5e8985503c42babb0c9
Rust
azazdeaz/good-bug
/drivers/src/bin/try_motors.rs
UTF-8
876
2.921875
3
[ "MIT" ]
permissive
use std::{thread, time::Duration}; use clap::{AppSettings, Clap}; /// This doc string acts as a help message when the user runs '--help' /// as do all doc strings on fields #[derive(Clap)] #[clap(setting = AppSettings::AllowLeadingHyphen)] struct Opts { #[clap(about("left side speed (between -1.0 an 1.0)"))] l...
true
c6beccf628a7e4550aa2a8e4d83d5ae8b0365770
Rust
cdriehuys/raytracer
/src/objects/plane.rs
UTF-8
3,202
3.484375
3
[ "MIT" ]
permissive
use crate::{ intersections::{Intersection, Intersections}, linear::Tuple, Ray, }; use super::{BaseShape, Shape}; /// A plane that extends infinitely along the x- and z-axis. #[derive(Clone, Debug, Default)] pub struct Plane { base: BaseShape, } impl Shape for Plane { fn base_shape(&self) -> &Base...
true
08ad38c7d5170ea8933f7f8c07d5d314df0e638a
Rust
russelltg/srt-rs
/srt-protocol/src/options/validation.rs
UTF-8
7,149
3.359375
3
[ "Apache-2.0" ]
permissive
use std::ops::Deref; pub trait Validation: Sized { type Error; fn is_valid(&self) -> Result<(), Self::Error>; fn try_validate(self) -> Result<Valid<Self>, Self::Error> { self.is_valid()?; Ok(Valid(self)) } } pub trait CompositeValidation: Validation { fn is_valid_composite(&self)...
true
a1374c9f0b672f0e7abab09861d9897db110055c
Rust
Jakobzs/rs-cache
/src/ldr/osrs.rs
UTF-8
1,400
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Example //! //! ``` //! use rscache::OsrsCache; //! use rscache::ldr::osrs::ItemLoader; //! //! # fn main() -> rscache::Result<()> { //! let cache = OsrsCache::new("./data/cache")?; //! let item_ldr = ItemLoader::new(&cache)?; //! //! if let Some(def) = item_ldr.load(1042) { //! assert_eq!("Blue partyhat",...
true
c5bdf7414b20ccbbd352351a59a777be8833106b
Rust
Azure/azure-sdk-for-rust
/services/mgmt/devtestlabs/src/package_2015_05_preview/models.rs
UTF-8
86,128
2.546875
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "Request body for applying artifacts to a virtual machine."] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default...
true
81861a616750ca06265ac0ef7e1a54fbe1eec87c
Rust
Juici/strife
/src/constants.rs
UTF-8
2,613
2.953125
3
[ "MIT" ]
permissive
//! A collection of constants used by the library. /// The gateway version used by the library, URI is retrieved via the REST API. pub const GATEWAY_VERSION: usize = 6; /// The maximum length of textual size of an embed message. pub const EMBED_MAX_LENGTH: usize = 6000; /// The maximum length of a message in Unicode ...
true
2d69f3d20cda2f0cc4eaaeb6ddda6b0fa6c5b2a9
Rust
songlinshu/elvis
/core/src/value/border.rs
UTF-8
3,629
3.3125
3
[ "MIT" ]
permissive
use crate::value::{Color, Unit}; use elvis_core_support::{EnumStyle, Setter}; /// Border Style #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, EnumStyle)] pub enum BorderStyle { /// No Style None, /// Hidden Border Hidden, /// Dotted Border Dotted, /// Dashed Border Dashed, /...
true
c8d9cbcd3a7e4636bd1e65f85c5b037e0a006909
Rust
Canop/broot
/src/task_sync.rs
UTF-8
5,989
3.09375
3
[ "MIT" ]
permissive
use { crossbeam::channel::{self, bounded, select, Receiver}, std::thread, termimad::TimedEvent, }; pub enum Either<A, B> { First(A), Second(B), } #[derive(Debug, Clone)] pub enum ComputationResult<V> { NotComputed, // not computed but will probably be Done(V), None, // nothing to compu...
true
c1bf6a07c4f7c38e9f877b7679025fb45bfd440e
Rust
misut/rust_practice
/coin/src/main.rs
UTF-8
377
3.59375
4
[]
no_license
enum Coin { Penny, Nickel, Dime, Quarter, } impl Coin { fn value_in_cents(&self) -> u8 { match self { Coin::Penny => 1, Coin::Nickel => 5, Coin::Dime => 10, Coin::Quarter => 25, } } } fn main() { let penny = Coin::Penny; p...
true
a83884021c7a8ec2ad5d2de3ce852a1f2bbe952e
Rust
so61pi/examples
/rust/tests/src/ttrait.rs
UTF-8
1,411
3.484375
3
[ "MIT" ]
permissive
/// DBTrait for common interface. pub trait DBTrait { fn get_username(&mut self, id: u64) -> String; } /// DBReal is the real implementation of DBTrait. pub struct DBReal {} impl DBReal { pub fn new() -> DBReal { DBReal{} } } impl DBTrait for DBReal { fn get_username(&mut self, id: u64) -> St...
true
77e9f6d630c1a197ffbbcbe62a86ddabd872cc0d
Rust
spamwax/alfred-pinboard-rs
/src/commands/delete.rs
UTF-8
3,668
2.96875
3
[ "MIT" ]
permissive
/// Providing this command with a URL will try to remove the related bookmark from Pinboard. /// If no URL is provided, this command will fetch browser's tab info and show and Alfred item that /// can be used for deletion in next step. /// use super::{browser_info, io, Runner, SubCommand}; use crate::AlfredError; use a...
true
585d1e60dce3475906c3fa89394c8a8c06169cec
Rust
nilsmartel/druid
/druid-shell/src/backend/wayland/pointers.rs
UTF-8
14,993
2.71875
3
[ "Apache-2.0" ]
permissive
use std::collections::VecDeque; use wayland_client::protocol::wl_pointer; use wayland_client::protocol::wl_surface::{self, WlSurface}; use wayland_client::{self as wl}; use wayland_cursor::CursorImageBuffer; use wayland_cursor::CursorTheme; use crate::keyboard::Modifiers; use crate::kurbo::{Point, Vec2}; use crate::mo...
true
b7194fd0987589a2fc6809556bdecc1efd1af50c
Rust
involuble/phosphor
/src/geometry/sphere.rs
UTF-8
4,139
2.8125
3
[]
no_license
use crate::math::*; use embree::{Ray, UserPrimHit, UserPrimitive, AABB}; use crate::colour::*; use crate::geometry::{SampleableEmitter, LightSample}; use crate::sampling::*; #[derive(Debug, Clone)] pub struct Sphere { pub center: Point3<f32>, pub radius: f32, pub emission: Colour, } impl Sphere { pub ...
true
b9cf21b59193b2614b3451e2b522d112c12f9f49
Rust
yuyttenhove/slab_mcrt
/src/regular_grid_slab.rs
UTF-8
5,324
2.796875
3
[]
no_license
mod grid_cell; use grid_cell::GridCell; use crate::vector::Vec2; use crate::slab::Slab; use rand::Rng; pub struct RegularGridSlab { anchor: Vec2<f64>, sides: Vec2<f64>, resolution: i64, cells: Vec<GridCell>, } impl RegularGridSlab { pub fn new(tau_max: f64, albedo: f64, g: f64, resolution: i64) -...
true
2b4349a5a3e0153b74a850d90d8a2a0a5fc52485
Rust
RustWorks/openapi_generator-1
/src/helpers.rs
UTF-8
6,317
2.859375
3
[]
no_license
use anyhow::Result; use english_numbers; use handlebars::{ handlebars_helper, Context, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError, }; use json_pointer::JsonPointer; use serde_json::value::Value as Json; macro_rules! case_helper { ($name:ident, $function:ident) => { pub(crate) fn...
true
73b27706a300d28f2fa36599f7ef82dee4b63a24
Rust
benbromhead/loom
/src/rt/arc.rs
UTF-8
4,444
3.078125
3
[ "MIT" ]
permissive
use crate::rt::object; use crate::rt::{self, Access, Location, Synchronize, VersionVec}; use std::sync::atomic::Ordering::{Acquire, Release}; #[derive(Debug)] pub(crate) struct Arc { state: object::Ref<State>, } #[derive(Debug)] pub(super) struct State { /// Reference count ref_cnt: usize, /// Locat...
true
62f96174bc25ee6a66d731f55bd95bcef52b7bf1
Rust
snwallet/rust-np
/rust21/src/main.rs
UTF-8
757
3.765625
4
[ "Apache-2.0" ]
permissive
//1、rust中每一个引用都有其生命周期,也就是引用保持有效的作用域。大部分生命周期是隐含并可以推断的,正如大部分的时候类型可以推断一样 //2、生命周期的主要目标是避免悬垂引用 //3、rust编译器使用借用检查器来检查生命周期是否有效 //fn main() { // let r; // { // let x = 5; // r = &x; // println!("{}",r); // } // // //} //函数中的生命周期 //fn longest (x:&str,y:&str) -> &str{ fn longest<'a> (x:&'a str,y:...
true
0b780c43687da9d5d3f2b0181658b4dd4c494e8a
Rust
Oyelowo/coding_practice
/rust/timer/src/main_pin_heap.rs
UTF-8
1,524
3.46875
3
[]
no_license
use std::pin::Pin; use std::marker::PhantomPinned; // Pinning to the Heap #[derive(Debug)] struct Test { a: String, b: *const String, _marker: PhantomPinned, } impl Test { fn new(txt: &str) -> Pin<Box<Self>> { let t = Test { a: String::from(txt), b: std::ptr::null(), ...
true
3d11d56c418167ff8df78059c3860aa556c1c82a
Rust
hugwijst/rtmpl
/src/attr_type.rs
UTF-8
4,069
3.109375
3
[]
no_license
use syntax::ast::{Expr, Ident, UnOp}; use syntax::codemap::Span; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; use syntax::ptr::P; #[derive(Debug,Clone,Eq,PartialEq)] pub enum AttrType { String, Int, Uint, Sequence(Box<AttrType>), //Map, //Set, //Model } impl AttrType...
true
7b4407914d149be3c0a1ecff887241ecc956411b
Rust
dmitmel/game-of-life-cluster
/src/master/server.rs
UTF-8
3,351
2.671875
3
[ "MIT" ]
permissive
// extern crate slab; // use self::slab::Slab; use std::collections::HashMap; use super::mio::tcp::TcpListener; use super::mio::{Event, Poll, PollOpt, Ready, Token}; use std::io::Result as IoResult; use super::connection::Connection; use super::utils::assert_event_readiness; use utils::result::DescribeErr; const SE...
true
67b679595d566847ad6318ee22433e30efea1864
Rust
TheRawMeatball/quoridor
/quoridor_core/src/rulebooks/standard_rulebook.rs
UTF-8
14,516
2.78125
3
[]
no_license
use crate::*; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct StandardQuoridor; fn check_movable( game: &QGame<StandardQuoridor>, pawn_pos: Position, pos: Position, check_jump: bool, ) -> Result<(), ()> { let x = pawn_pos.x as i8 - pos.x as i8; let y = pawn_pos.y as i8 - pos.y as i8...
true
8f6e09b8eda10a584e6fe9e8e85465a3a18aa78e
Rust
informalsystems/ibc-proto
/ibc_prost_compiler/src/main.rs
UTF-8
1,011
2.53125
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use std::fs::remove_dir_all; use std::fs::{copy, create_dir_all}; use walkdir::WalkDir; pub(crate) fn main() { let ibc_proto_path = "ibc_proto/src/prost"; // Remove old compiled files remove_dir_all(ibc_proto_path).unwrap_or_default(); create_dir_all(ibc_proto_path).unwrap(); // Copy new compiled...
true
0456a2ba9b17b9b08855c0d636668d13af9a773f
Rust
scott113341/advent_of_code_2020
/day_17/src/main.rs
UTF-8
1,844
3.34375
3
[]
no_license
use crate::data_3d::CubeGrid; use crate::data_4d::HyperCubeGrid; mod data_3d; mod data_4d; fn main() { let input = include_str!("input.txt").trim(); println!("part_1: {}", part_1(&input)); println!("part_2: {}", part_2(&input)); } // Starting with your given initial configuration, simulate six cycles. Ho...
true
f728d73afea83b2099318b9f32c4da3d37396997
Rust
Xiyng/gamemaps-parser-rust
/src/gamemaps_parser/compression/rlew/mod.rs
UTF-8
1,898
3.046875
3
[ "MIT" ]
permissive
#[cfg(test)] mod tests; extern crate byteorder; use std::fmt; use self::byteorder::*; pub fn decode(data: &Vec<u8>, tag: u16, decoded_length_words: Option<usize>) -> Result<Vec<u16>, RlewDecodeError> { if data.len() % 2 != 0 { // TODO: Things seem to be working out very well even without this, so ...
true
ab28a0cefecc02c7d9a13e4e267e1c7be0be13b7
Rust
tensorbase/tensorbase
/crates/arrow/src/bytes.rs
UTF-8
4,901
2.90625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
5c31612403e49f1152416f80bfa1ce064b48ace0
Rust
KBone12/nand2tetris-rs
/debugger/src/main.rs
UTF-8
2,527
3.171875
3
[]
no_license
use std::io::Write; use clap::{app_from_crate, crate_authors, crate_description, crate_name, crate_version, Arg}; use computer::{ keyboard::DummyKeyboard as Keyboard, rom::Rom, screen::DummyScreen as Screen, Computer, }; fn print_help() { println!( r#"commands: help: Show this help show: Show...
true
55d8ef67aed9feea6d3f954f211538592037f90a
Rust
sindreij/advent-of-code-2020
/aoc08/src/main.rs
UTF-8
4,025
3.390625
3
[]
no_license
use std::{ cmp::max, collections::{HashMap, HashSet}, fs::read_to_string, ops::RangeInclusive, }; use anyhow::{anyhow, bail, Result}; use maplit::{hashmap, hashset}; fn main() -> Result<()> { println!("part1: {}", part1(&read_input()?)?); println!("part2: {}", part2(&read_input()?)?); Ok(...
true
aed07e4da373f43bbecf3b6761903b0fd18d16ef
Rust
provotum/generator-rs
/src/main.rs
UTF-8
4,741
2.828125
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
extern crate clap; #[macro_use] extern crate log; extern crate pretty_env_logger; extern crate env_logger; extern crate crypto_rs; extern crate generator_rs; extern crate serde_json; use env_logger::Target; use crypto_rs::el_gamal::encryption::{PublicKey, PrivateKey}; use generator_rs::generator::Generator; use gener...
true
15fa85d195d7f7abc6af016a5c13318b6dab9c30
Rust
gen0083/atcoder_python
/rust/abc209/src/bin/c.rs
UTF-8
387
2.5625
3
[]
no_license
use proconio::input; fn main() { input!{ n: isize, mut c: [u64; n] } c.sort(); let mut ans: u64 = 1; let base = 1_000_000_007u64; for (i, v) in c.iter().enumerate() { let f = v - i as u64; if f == 0 { println!("0"); return; } ...
true
08f87862086ce2c8256a6a6c0e6959ebf027fd0e
Rust
iCodeIN/raytracer
/src/color.rs
UTF-8
1,440
3.40625
3
[]
no_license
use crate::utils::{avg,clamp}; #[derive(Debug, Copy, Clone, PartialEq)] pub struct Color(pub f32, pub f32, pub f32); impl Color { pub fn gray(value: f32) -> Self { Self(value, value, value) } pub fn to_u8(&self) -> [u8;3] { [ clamp(self.0 * 255.0, 0.0, 255.0) as u8, ...
true
57bf2fe821fb56f54da39972bc4bd6a7e1aefee0
Rust
JPMoresmau/rtext
/src/index.rs
UTF-8
4,532
2.796875
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] pub struct Index { last_id: u128, last_op: u128, docs: HashMap<u128,HashMap<String,f64>>, terms: HashMap<String,Vec<u128>>, idfs: HashMap<String, (u128,f64)>, tfidfs: HashMap<String, Vec<(u128,f64)>>, doc_tfidfs: HashMap<u128, Vec<(String, f64...
true
a39e7f419f5a7fa8233dfde7c59c4bcd52c7c8a2
Rust
sudharsh/vector
/lib/file-source/src/file_watcher.rs
UTF-8
9,708
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::fs; use std::io::{self, BufRead, Seek}; use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::time; /// The `FileWatcher` struct defines the polling based state machine which reads /// from a file path, transparently updating the underlying file descriptor when /// the file has been rolled over...
true
b8039d1a94c952386567a682135dcf1a87758f4f
Rust
elferherrera/arrow
/rust/arrow/src/json/writer.rs
UTF-8
21,732
2.75
3
[ "Apache-2.0", "BSD-3-Clause", "CC0-1.0", "OpenSSL", "NTP", "ZPL-2.1", "JSON", "BSL-1.0", "MIT", "LLVM-exception", "LicenseRef-scancode-public-domain", "Zlib", "BSD-2-Clause", "CC-BY-3.0", "LicenseRef-scancode-unknown-license-reference", "CC-BY-4.0", "LicenseRef-scancode-protobuf" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
e09ef6af545ddc1dc29a28b66ca5393e6f94c7e7
Rust
oberblastmeister/bulk-rename
/src/opt.rs
UTF-8
717
3
3
[]
no_license
use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] pub struct Opt { /// allow hidden directories to be shown #[structopt(short = "H", long)] pub hidden: bool, /// search through directories recursively #[structopt(short = "R", long)] pub recursive: bool, /// sho...
true
90dc3dc14ae14842ba849e4676fcae0be84642b2
Rust
lambdax-x/algolia-challenge
/src/tree/heap.rs
UTF-8
2,311
3.484375
3
[]
no_license
pub struct MinHeap<T> { nodes: Vec<T> } // Helpers for indexing macro_rules! index { (root) => (0); (parent, $i: expr) => (($i - 1) >> 1); (left, $i: expr) => (($i << 1) | 1); (right, $i: expr) => (($i + 1) << 1); } impl<T: Copy + Ord> MinHeap<T> { pub fn new() -> Self { MinHeap { ...
true
84fa39de0a48a24e7ae271dc3a806b6f13e46039
Rust
glalonde/spout
/src/color_maps.rs
UTF-8
2,738
2.5625
3
[]
no_license
use wgpu::util::DeviceExt; #[allow(dead_code)] #[repr(u8)] #[derive(Copy, Clone)] enum ColorMap { Viridis = 0, Magma = 1, Inferno = 2, Plasma = 3, } use lazy_static::lazy_static; lazy_static! { static ref COLOR_MAPS: [scarlet::colormap::ListedColorMap; 4] = [ scarlet::colormap::ListedColor...
true
f48e8f496118bbbf45b14c4f0981ed1d6c107a53
Rust
ajay340/Flax
/src/repl.rs
UTF-8
3,375
3.328125
3
[]
no_license
use std::io; use std::io::Write; use std::env; use crate::lexer; use crate::interpreter; use crate::parser; use parser::{Parser}; use colored::*; pub fn run_repl() { //Check if REPL was run with args let args: Vec<String> = env::args().collect(); if args.len() > 1 { let filename = &args[1]; ...
true
2c9a58f5f80bcc4bb3d44a484a36a252cd4ed44f
Rust
KSXGitHub/dirt
/src/data_tree/sort.rs
UTF-8
731
2.9375
3
[ "Apache-2.0" ]
permissive
use super::DataTree; use crate::size::Size; use rayon::prelude::*; use std::cmp::Ordering; impl<Name, Data> DataTree<Name, Data> where Self: Send, Data: Size, { /// Sort all descendants recursively, in parallel. pub fn par_sort_by(&mut self, compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync) { ...
true
f34511d9be4946c609555c26df6ed4790948f1da
Rust
fossabot/radvisor
/src/polling/providers/errors.rs
UTF-8
1,712
3.21875
3
[ "MIT" ]
permissive
use std::error; use std::fmt; /// An error that occurred during container metadata fetching #[derive(Debug)] pub struct FetchError { cause: Option<Box<dyn error::Error>>, } impl FetchError { /// Creates a new fetch error, optionally using an error instance pub fn new(cause: Option<Box<dyn error::Error>>) ...
true
ec492db70565d2b49d28c3da066fab028b6fbc02
Rust
mdsherry/aoc2020
/day-23/src/part1.rs
UTF-8
935
3.28125
3
[]
no_license
use std::collections::VecDeque; fn do_the_mario(cups: &mut VecDeque<u32>) { // Active is always in front let current = cups.pop_front().unwrap(); let a = cups.pop_front().unwrap(); let b = cups.pop_front().unwrap(); let c = cups.pop_front().unwrap(); let mut target = if current == 1 { 9 } else ...
true
719f9657b9a2c3a432a128263bc10ee736e4a354
Rust
FoseFx/UltimateGymWue
/UGWBackend/src/redismw.rs
UTF-8
2,361
2.765625
3
[]
no_license
use rocket::http; use rocket::request; use rocket::Outcome; use rocket::State; use r2d2_redis::RedisConnectionManager; use std::env::vars; use std::process::Command; pub fn pool() -> r2d2::Pool<RedisConnectionManager> { let mut redis_full_path: Option<String> = Option::None; for (env_key, val) in vars(){ ...
true
ebe95712ffd9985f78f0d2363d59fb5584b26399
Rust
therealprof/embedded-bridge
/bridge-host/src/io.rs
UTF-8
7,656
2.703125
3
[ "BSD-2-Clause" ]
permissive
use bridge_common::encoding::{ clear, gpio_init_pp, gpio_sethigh, gpio_setlow, gpio_toggle, i2c_init, i2c_write, reset, spi_init, spi_write, version, Reply, Request, }; use heapless::{consts::*, Vec}; use postcard::{from_bytes, to_vec}; use std::io::{Error, ErrorKind, Read, Result, Write}; type BufferLength = ...
true
0f7a39916a83245815db7e91dfcd36b56bdf81a4
Rust
cookpad/sds
/src/types.rs
UTF-8
1,136
2.640625
3
[]
no_license
use serde_derive::{Deserialize, Serialize}; use std::error; use std::fmt; pub trait Storage: Send + Sync + Clone + 'static { type E: fmt::Display + error::Error; fn query_items(&self, name: &str) -> Result<Vec<Host>, Self::E>; fn store_item(&self, name: &str, host: Host) -> Result<(), Self::E>; fn dele...
true
e7b5aa0f1d3f50f82286e7c14305a63d3b0a22da
Rust
ToF-/WordLadder
/Rust/word_ladder/src/main.rs
UTF-8
954
3.03125
3
[]
no_license
#[macro_use] extern crate structopt; mod word_graph; use std::fs::File; use std::io::Read; use std::path::PathBuf; use structopt::StructOpt; use word_graph::WordGraph; #[derive(Debug, StructOpt)] #[structopt(name = "word_ladder", about = "Finding ladders between words.")] struct Opt { /// Path to the word dictio...
true
891834ef07859af80eb7b6d9be54748fae390a45
Rust
rustysec/entropy-rs
/examples/example1.rs
UTF-8
937
3.015625
3
[ "MIT" ]
permissive
extern crate entropy_rs; use entropy_rs::{Entropy, Shannon}; use std::env; use std::fs::File; use std::io::prelude::*; fn main() -> std::io::Result<()> { if env::args().len() == 1 { println!("Please specify one or more file names."); return Ok(()); } const BLOCK_SIZE: usize = 1024; en...
true
23ff6da3eec7ac382cc1417d35ee90ad0f840eec
Rust
nervosnetwork/ckb
/script/src/syscalls/current_cycles.rs
UTF-8
847
2.609375
3
[ "MIT" ]
permissive
use crate::syscalls::CURRENT_CYCLES; use ckb_vm::{ registers::{A0, A7}, Error as VMError, Register, SupportMachine, Syscalls, }; #[derive(Debug, Default)] pub struct CurrentCycles { base: u64, } impl CurrentCycles { pub fn new(base: u64) -> Self { Self { base } } } impl<Mac: SupportMachin...
true
01ee16f289379423e8e89893447e00ad75cb1bd9
Rust
tomhoule/prisma-engine
/query-engine/prisma/src/request_handlers/graphql/schema_renderer/enum_renderer.rs
UTF-8
982
3.03125
3
[ "Apache-2.0" ]
permissive
use super::*; use prisma_models::{EnumType, EnumValue}; pub struct GqlEnumRenderer<'a> { enum_type: &'a EnumType, } impl<'a> Renderer for GqlEnumRenderer<'a> { fn render(&self, ctx: RenderContext) -> (String, RenderContext) { if ctx.already_rendered(&self.enum_type.name) { return ("".into(...
true
bcbc7d61f682b956dddb1fe7b312628cdffe1c58
Rust
DiesDasJenes/advent_of_code
/2021/aoc_d1/src/main.rs
UTF-8
2,487
3.421875
3
[]
no_license
mod util; use std::ops::Add; use std::str::FromStr; fn main() { if let Ok(lines) = util::read_lines("./puzzle_input.txt") { let numbers = lines .flat_map(|number| u32::from_str(number.unwrap().as_str())) .collect::<Vec<u32>>(); let count = count_increases_of_measurements(&nu...
true
68d1daef3dcfe04fbeb8bd416824b1a4bcde2372
Rust
Elzair/filearco_rs
/src/file_data.rs
UTF-8
11,464
3.65625
4
[ "Apache-2.0", "MIT" ]
permissive
//! This module contains a function `get()` to retrieve a list of all ordinary //! files in a given directory hierarchy. //! //! # Example //! //! ```rust //! extern crate filearco; //! //! use std::path::Path; //! //! let path = Path::new("testarchives/simple"); //! let file_data = filearco::get_file_data(path).unwrap...
true
69ce903b27a9c13032c3b640dbcf18a28ecff260
Rust
iCodeIN/cm
/src/cm/config.rs
UTF-8
180
2.671875
3
[ "MIT" ]
permissive
pub fn split_key_value(line: &str) -> Option<(&str, &str)> { line.find('=').map(|pos| { let (lh, rh) = line.split_at(pos); (lh.trim(), rh[1..].trim()) }) }
true
f96e9c97730fd9f933b3b75d2f8b18c90cadf693
Rust
yskszk63/historify
/examples/original/src/main.rs
UTF-8
167
2.640625
3
[]
no_license
mod sub { pub use std::println as puts; } use sub::puts; fn main() { use std::rc::Rc; let _ = Rc::new(0); puts!("Hello, world! {:?}", Rc::new(0)); }
true
42d5fe6deb50fddff495fe057073390846b1e908
Rust
exoego/ouch
/src/oof/util.rs
UTF-8
452
3.296875
3
[ "MIT" ]
permissive
/// Util function to skip the two leading long flag hyphens. pub fn trim_double_hyphen(flag_text: &str) -> &str { flag_text.get(2..).unwrap_or_default() } #[cfg(test)] mod tests { use super::trim_double_hyphen; #[test] fn _trim_double_hyphen() { assert_eq!(trim_double_hyphen("--flag"), "flag")...
true
db1349e3a2ed3ddc07156e0a368eed63394f872d
Rust
qeedquan/challenges
/leetcode/power-of-two.rs
UTF-8
281
3.5625
4
[ "MIT" ]
permissive
/* Given an integer, write a function to determine if it is a power of two. */ fn main() { for i in 1..(1 << 20) + 1 { if is_power_of_two(i) { println!("{}", i); } } } fn is_power_of_two(n: usize) -> bool { n > 0 && (n & (n - 1)) == 0 }
true
450faad5db2db96c2733d603765d05a24ac17ee3
Rust
isgasho/doku
/doku/src/printers/json/print_array/expand_variants/for_externally_tagged_enum.rs
UTF-8
1,847
2.734375
3
[ "MIT" ]
permissive
use super::*; impl<'ty> Ctxt<'ty, '_> { pub fn expand_variants_for_externally_tagged_enum(&mut self, ty: &'ty Type) -> bool { let variants = if let TypeDef::Enum { tag: Tag::External, variants, } = &ty.def { variants } else { return fa...
true
6e53e0d91fa57253f0d7dccdef7c7934dbec66ed
Rust
polo-sec/practical_rust
/data_structures/src/main.rs
UTF-8
109
2.5625
3
[]
no_license
fn main() { let mut tryhackme: u32 = 9; println!("The tryhackme variable equals: {}", tryhackme); }
true
fd4549afe40fd878fee7f5c0074dac67dc730240
Rust
Happy-Ferret/libsyntax2
/crates/libsyntax2/src/ast/mod.rs
UTF-8
2,984
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
mod generated; use std::sync::Arc; use itertools::Itertools; use smol_str::SmolStr; use { SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError, SyntaxKind::*, }; pub use self::generated::*; pub trait AstNode<R: TreeRoot> { fn cast(syntax: SyntaxNode<R>) -> Option<Self> where Self: Sized;...
true