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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
eb02567fe60e8e686128186ad462be7a1dc1b242 | Rust | rcore-os/zCore | /linux-syscall/src/file/file.rs | UTF-8 | 19,379 | 3 | 3 | [
"MIT"
] | permissive | //! File operations
//!
//! - read, pread, readv
//! - write, pwrite, writev
//! - lseek
//! - truncate, ftruncate
//! - sendfile, copy_file_range
//! - sync, fsync, fdatasync
//! - ioctl, fcntl
//! - access, faccessat
use super::*;
use linux_object::{process::FsInfo, time::TimeSpec};
impl Syscall<'_> {
/// Reads... | true |
bfc485943f6cf13172107f160f927ae3fe50bbb2 | Rust | Woyten/tune | /src/temperament.rs | UTF-8 | 21,143 | 3.0625 | 3 | [
"MIT"
] | permissive | //! Explore equal temperaments and vals.
use std::fmt::Display;
use crate::{
comma::Comma,
math,
pergen::{AccidentalsFormat, AccidentalsOrder, NoteFormatter, PerGen},
pitch::Ratio,
};
#[derive(Clone, Debug)]
pub struct EqualTemperament {
temperament_type: TemperamentType,
primary_step: i16,
... | true |
39563223368b46569986b9e930afec52991d5ec9 | Rust | pco2699/algorithms | /wis/src/main.rs | UTF-8 | 2,616 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader, Error};
use std::str::FromStr;
use std::cmp;
use std::collections::HashSet;
type WeightList = Vec<usize>;
macro_rules! set {
( $( $x:expr ),* ) => { // Match zero or more comma delimited items
{
let mut temp_set = HashSet::new(); // Creat... | true |
ce7e2cf1f8efcaa7e97c428988e27dec8517adde | Rust | the10thWiz/rocket-tungstenite | /examples/echo.rs | UTF-8 | 2,318 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | //! A simple echo websocket example
//!
//! Spawns a rocket server, with two routes; '/', a static file, and '/echo', a websocket route.
//! The main file will use JS to open a websocket connection back to the server, on the echo route.
//! The websocket will simply repeat any message back to the client.
//!
//! Use `c... | true |
e1b3354a61a65fbe403403345df9bce573e23365 | Rust | marcmo/rustScripts | /clean_vim_mru_file.rs | UTF-8 | 2,217 | 3.109375 | 3 | [] | no_license | use std::path::Path;
use std::io;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::fs;
use std::vec::Vec;
use std::error::Error;
static BACKUP_FILE: &'static str = ".vim_mru_files_backup";
static MRU_FILE: &'static str = ".vim_mru_files";
fn does_file_exist(path: &Path) -> bool {
std::... | true |
6e1b4ad6b560eb4355d54e632252d266337cf1ca | Rust | kaj/rsass | /rsass/tests/spec/core_functions/color/hue.rs | UTF-8 | 2,620 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Tests auto-converted from "sass-spec/spec/core_functions/color/hue.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("hue")
}
#[test]
fn above_max() {
assert_eq!(
runner().ok("a {b: hue(hsl(540, 50%, 50%))}\n"),
"a {\
\n b: 180deg;\
\n}\n"... | true |
500bac44ffa62f0844bb356d9f6f1a1a920fb78a | Rust | kellerkompanie/kellerkompanie-sync-rust | /kellerkompanie-sync/src/hashing.rs | UTF-8 | 849 | 2.796875 | 3 | [] | no_license | extern crate ring;
use std::fs::File;
use std::io::{BufReader, Read};
use data_encoding::HEXUPPER;
use ring::digest::{Context, Digest, SHA256};
pub fn hash_file(path: &String) -> String {
let input = match File::open(path) {
Ok(file) => file,
Err(error) => {
panic!("Problem opening fi... | true |
943f219ca95a4e10eef8df40d969d24b723db5b7 | Rust | seanwallawalla-forks/nushell | /crates/nu_plugin_start/src/start.rs | UTF-8 | 8,647 | 2.765625 | 3 | [
"MIT"
] | permissive | use nu_errors::ShellError;
use nu_protocol::{CallInfo, Value};
use nu_source::{Tag, Tagged, TaggedItem};
use std::path::Path;
#[cfg(not(target_os = "windows"))]
use std::process::{Command, Stdio};
#[derive(Default)]
pub struct Start {
pub tag: Tag,
pub filenames: Vec<Tagged<String>>,
pub application: Optio... | true |
261ff683064dbaa584a64ab06f969438d7f4559b | Rust | ayax79/rust-bookstore | /src/model.rs | UTF-8 | 3,758 | 3.34375 | 3 | [] | no_license | use crate::errors::BookServiceError;
use serde::de::{self, Visitor};
use serde::{Deserializer, Serializer};
use serde_json;
use std::fmt;
use uuid::Uuid;
#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
pub struct Book {
#[serde(
serialize_with = "serialize_uuid",
deserialize_... | true |
f27177467ee515ea7651b662b80e39907f9cb8e2 | Rust | MJJoyce/Advent-Of-Code-2020 | /day10/src/day10.rs | UTF-8 | 4,874 | 3.265625 | 3 | [] | no_license | use std::collections::{HashMap, VecDeque};
use std::fs::File;
use std::io::{BufRead, BufReader};
pub fn load_data() -> Vec<u64> {
let br = BufReader::new(File::open("./input/input.txt").unwrap());
let mut adapters = vec![0];
for line in br.lines() {
let line = line.unwrap();
adapters.push(l... | true |
3e731129c44a4c1e6df166110f66208ce542aa3f | Rust | tsunrise/utils | /std/src/lib.rs | UTF-8 | 3,113 | 2.984375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
#[doc(hidden)]
extern crate alloc;
#[cfg(not(feature = "std"))]
pub use alloc::*;
#[cfg(not(feature = "std"))]
pub use core::*;
#[cfg(not(feature = "std"))]
pub mod fmt {
pub use alloc::fmt::*;
pub use core::fmt::*;
}
#[cfg(not(feature... | true |
c169aca1bdbfe6c89103816a26c881b086309007 | Rust | netsle-monitoring/restapi | /src/crypto/mod.rs | UTF-8 | 1,376 | 2.65625 | 3 | [] | no_license | use ring::{digest, pbkdf2};
mod config;
static PBKDF2_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256;
const CREDENTIAL_LEN: usize = digest::SHA256_OUTPUT_LEN;
type Credential = [u8; CREDENTIAL_LEN];
pub enum Error {
WrongUsernameOrPassword,
}
/**
* Hash a password based on the username of the client
*/
pu... | true |
9ba1d17a1b83d2d3eb37fae7f7e2dc9c7d94c916 | Rust | melted/aoc2017 | /src/bin/day17.rs | UTF-8 | 724 | 3.25 | 3 | [] | no_license | fn spinlock1(n : usize) -> usize {
let mut spinlock = Vec::new();
let step : usize = 359;
let mut pos : usize = 0;
spinlock.push(0);
for i in 1..n+1 {
pos = (pos + step) % i;
if pos == i-1 {
spinlock.push(i)
} else {
spinlock.insert(pos + 1, i);
... | true |
b551e686d169e85ec4d27278a01ababdd4ee8d88 | Rust | gwy15/leetcode | /src/que-shi-de-shu-zi-lcof.rs | UTF-8 | 807 | 3.5 | 4 | [] | no_license | struct Solution;
impl Solution {
pub fn missing_number(nums: Vec<i32>) -> i32 {
if nums[0] != 0 {
return 0;
}
let mut left = 0;
let mut right = nums.len();
// [left, right)
while left + 1 < right {
let i = (left + right) / 2;
if nu... | true |
554c50e6d1b096e9811213174b0f389de975877f | Rust | tspooner/rstat | /src/univariate/bernoulli.rs | UTF-8 | 5,326 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::{
fitting::{Likelihood, Score, MLE},
statistics::{FisherInformation, Modes, Quantiles, ShannonEntropy, UvMoments},
univariate::binomial::Binomial,
Convolution,
DiscreteDistribution,
Distribution,
Probability,
Univariate,
};
use spaces::discrete::{Binary, binary};
use std::fmt;... | true |
43157606cdbfcf3c2e6f884e066640772cd9ffbc | Rust | adarshpannu/leetcode | /src/lc564_closest_palindrome.rs | UTF-8 | 2,102 | 3.515625 | 4 | [] | no_license | struct Solution;
impl Solution {
fn to_digits(n: &String) -> Vec<i32> {
n.chars()
.map(|ch| ch as i32 - '0' as i32)
.collect::<Vec<i32>>()
}
fn to_num(v: &Vec<i32>) -> i32 {
v.into_iter().fold(0, |acc, e| acc * 10 + e)
}
fn reflect(digits: &mut Vec<i32>) {
... | true |
d6196b378e2a31c24f3a7510c8c1f9ae7644ecec | Rust | jlricon/advent-2020 | /src/bin/day20b.rs | UTF-8 | 6,466 | 3.046875 | 3 | [] | no_license | #[derive(Clone)]
pub struct Orientation {
pub reflect: bool,
pub rotate: u8,
}
impl Iterator for Orientation {
type Item = Orientation;
fn next(&mut self) -> Option<Orientation> {
let result = self.clone();
self.rotate = (self.rotate + 1) % 4;
if self.rotate == 0 {
... | true |
8c333cbba8db78ce55286fac8afa68369b5230bd | Rust | Kobzol/intellij-rust | /src/test/resources/org/rust/lang/core/parser/fixtures/partial/types.rs | UTF-8 | 175 | 2.671875 | 3 | [
"MIT"
] | permissive | fn foo<'a, 'b>() where for<'c> 'a : 'b {}
type T = () + A;
type X = ;
fn bar() {
let a = b as ;
}
type T1 = [
type T2 = &;
type T3 = *;
type T4 = fn(;
type T5 = for<;
| true |
2f9d41889b16ce0348a68b745d68ab473505d6da | Rust | villor/rustia | /crates/protocol/src/packet/login.rs | UTF-8 | 4,197 | 2.671875 | 3 | [] | no_license | use bytes::{Buf, BufMut, BytesMut};
use super::{PacketError, BytesMutExt, PacketRead, PacketWrite, PacketPayload};
use crate::gen_packet_types;
gen_packet_types!(LoginServerPacket; LoginServerPacketKind;
( Error, 10 ),
( Error2, 11 ),
( Motd, 20 ),
( SessionKey, 40 )... | true |
ade6a0633c9fa7e55f333876a5dcb100b973f62d | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/handlebars/src/partial.rs | UTF-8 | 7,060 | 2.703125 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | use std::iter::FromIterator;
use hashbrown::HashMap;
use crate::context::{merge_json, Context};
use crate::error::RenderError;
use crate::output::Output;
use crate::registry::Registry;
use crate::render::{Directive, Evaluable, RenderContext, Renderable};
use crate::template::Template;
use crate::value::DEFAULT_VALUE;... | true |
841b587f6a1b099aa7c8166059c4f965cb319816 | Rust | Songbird0/rust-utils | /tests/two_tags.rs | UTF-8 | 488 | 3.046875 | 3 | [] | no_license | extern crate rustutils;
use rustutils::string::operations;
use std::error::Error;
#[test]
fn two_tags_successful_test_1() {
let foo = match operations::two_tags("`hello`".to_owned(), ("[inline]", "[/inline]"), "`") {
Ok(bbcode) => bbcode,
Err(error) => {
unreachable!(
"... | true |
ebfb831f3f09a6df4fd3670c5930c1c25fd976c2 | Rust | abusch/grit | /src/commit_state.rs | UTF-8 | 3,917 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use std::io::Write;
use anyhow::Result;
use git2::DiffFormat;
use minimad::TextTemplate;
use termimad::{Area, Event, FmtText, TextView};
use crate::{
context::AppContext,
git::CommitInfo,
keys::*,
screen::Screen,
state::{AppState, CommandResult},
};
/// Represents a line from the diff with its ty... | true |
bc8b3332940408ea2816a0f5b2c8b4118c711b15 | Rust | ergoplatform/sigma-rust | /ergotree-ir/src/chain/ergo_box/register.rs | UTF-8 | 12,009 | 2.875 | 3 | [
"CC0-1.0"
] | permissive | //! Box registers
use crate::mir::constant::Constant;
use crate::mir::expr::Expr;
use crate::serialization::sigma_byte_reader::SigmaByteRead;
use crate::serialization::sigma_byte_writer::SigmaByteWrite;
use crate::serialization::SigmaParsingError;
use crate::serialization::SigmaSerializable;
use crate::serialization::... | true |
08408b7b5c4a71390ac1895f7af0187de1f0f8e3 | Rust | JayKickliter/dsp | /src/math/dotproduct.rs | UTF-8 | 770 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::ops::{Add, Mul};
use num::Zero;
/// Returns the dot-product of two slices.
///
/// # Panics
/// Panics if `xs.len() != ys.len()`.
///
/// # Examples
/// ```
/// # use dsp::math::dotproduct::dot;
/// let xs = [1,2];
/// let ys = [1,2];
/// assert_eq!(5, dot(&xs, &ys));
/// ```
pub fn dot<T>(xs: &[T], ys: &[T])... | true |
9c42d63c446bccee24f5fa5a99bf93f936fd9291 | Rust | fowles/advent-of-code-2020 | /src/day8.rs | UTF-8 | 1,204 | 2.90625 | 3 | [] | no_license | use std::collections::HashSet;
#[aoc_generator(day8)]
fn gen(input: &str) -> Vec<(String, i64)> {
input.lines().map(|s| {
scan_fmt::scan_fmt!(s, "{} {}", String, i64).unwrap()
}).collect()
}
fn eval(prog: &[(String, i64)]) -> (i64, i64) {
let mut acc: i64 = 0;
let mut ic: i64 = 0;
let mut... | true |
4311eb92964fe506f8567a6addf9e8eb4ae1ab03 | Rust | ods/leetcode-rs | /src/challenge_2021_mar/week3/design_tinyurl.rs | UTF-8 | 3,153 | 3.359375 | 3 | [] | no_license | // Encode and Decode TinyURL
// https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/590/week-3-march-15th-march-21st/3673/
use std::{
cell::{RefCell, RefMut},
collections::HashMap,
rc::Rc,
};
pub struct Codec(RefCell<(HashMap<Rc<String>, usize>, Vec<Rc<String>>)>);
const ALPHABET:... | true |
5dce00f97811f5f68a0e9fc405de4d2521baf17e | Rust | DelSkayn/rquickjs | /core/src/value/function/args.rs | UTF-8 | 9,179 | 2.640625 | 3 | [
"MIT"
] | permissive | use crate::{
function::{Flat, Opt, Rest, This},
qjs, Ctx, FromJs, Function, IntoJs, Result, Value,
};
use super::{ffi::defer_call_job, Constructor};
const ARGS_ON_STACK: usize = 4;
pub enum ArgsSlice {
Stack {
slice: [qjs::JSValue; ARGS_ON_STACK],
offset: u8,
},
Heap(Vec<qjs::JSVa... | true |
d163e1dc83e43b421450aa284117583a55e01cda | Rust | JulianKnodt/mat-fst | /benches/benchmarks.rs | UTF-8 | 2,716 | 2.609375 | 3 | [] | no_license | use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use sparse_mat::{matrix::Matrix, output::FiniteFloat, util::compute_threshold};
use std::{
fs::File,
io::{BufRead, BufReader},
path::Path,
time::Duration,
};
fn file() -> File {
let p = Path::new(file!())
.parent()
.... | true |
f89c4f31d0a6269c4f80e3cc47986f3e0a2c36a8 | Rust | cm-wada-yusuke/yukicoder-rust | /src/188.rs | UTF-8 | 514 | 2.921875 | 3 | [] | no_license | fn main() {
let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
let mut happy_day: u32 = 0;
for month in 1..=12 {
for day in 1..=days[month as usize - 1] {
let day_char = format!("{:02}", day).to_string();
if month
== day_char[0].to_string().parse::<... | true |
6b9908cfe1c7a82221cb0999af62166f7d724b25 | Rust | Walters-Kuo/book-tw | /listings/ch15-smart-pointers/listing-15-20/src/lib.rs | UTF-8 | 951 | 3.65625 | 4 | [
"Apache-2.0",
"BSD-3-Clause",
"NCSA",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | pub trait Messenger {
fn send(&self, msg: &str);
}
pub struct LimitTracker<'a, T: Messenger> {
messenger: &'a T,
value: usize,
max: usize,
}
impl<'a, T> LimitTracker<'a, T>
where
T: Messenger,
{
pub fn new(messenger: &T, max: usize) -> LimitTracker<T> {
LimitTracker {
messe... | true |
2cbe3eecaffd127a82c46925bb3bd5ca5ab3436e | Rust | mdcg/a-tour-of-rust | /7-poo/7-funcoes-genericas.rs | UTF-8 | 1,324 | 3.796875 | 4 | [
"MIT"
] | permissive | // Os genéricos no Rust trabalham lado a lado com as traits. Quando
// descrevemos um tipo parametrizado T, podemos restringir quais
// tipos podem ser usados como argumento listando as traits
// necessárias que o argumento deve implementar.
// Neste exemplo o tipo T deve implementar a trait Foo:
// fn minha_funcao<T... | true |
c73a6c9dfd09001fea272de5d08ab3dfed9c3ff8 | Rust | acshi/jlrs | /jlrs/src/lib.rs | UTF-8 | 32,429 | 3.5625 | 4 | [
"MIT"
] | permissive | //! jlrs is a crate that provides access to most of the Julia C API, it can be used to embed Julia
//! in Rust applications and to use functionality from the Julia C API when writing `ccall`able
//! functions in Rust. Currently this crate is only tested on Linux in combination with Julia 1.6
//! and is not compatible w... | true |
eb3411cbc0718debfef65ce77385b28a57b986c2 | Rust | lawliet89/ferrous-chloride | /lib/src/parser/literals/number.rs | UTF-8 | 2,205 | 3.5 | 4 | [
"MIT"
] | permissive | use std::str::FromStr;
use nom::recognize_float;
use nom::types::CompleteStr;
use nom::{call, flat_map, named, parse_to};
/// Parsed Number
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum Number {
Integer(i64),
Float(f64),
}
impl<'a> From<Number> for crate::value::Value<'a> {
fn from(number: Number) ->... | true |
24af4420579befd54181dd05c0916c9760ae6f35 | Rust | rust-lang/cargo | /src/cargo/util/config/path.rs | UTF-8 | 3,478 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"Apache-2.0",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"OpenSSL",
"curl",
"LGPL-2.1-only",
"BSD-2-Clause",
"LicenseRef-scancode-ssleay-windows",
"Unlicense"
] | permissive | use super::{Config, UnmergedStringList, Value};
use serde::{de::Error, Deserialize};
use std::path::PathBuf;
/// Use with the `get` API to fetch a string that will be converted to a
/// `PathBuf`. Relative paths are converted to absolute paths based on the
/// location of the config file.
#[derive(Debug, Deserialize, ... | true |
52b5b94bcf4fafaa33d0942c1409a33269cdbb03 | Rust | rust-lang/miri | /tests/pass/concurrency/thread_locals.rs | UTF-8 | 1,534 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@compile-flags: -Zmiri-strict-provenance
//! The main purpose of this test is to check that if we take a pointer to
//! thread's `t1` thread-local `A` and send it to another thread `t2`,
//! dereferencing the pointer on `t2` resolves to `t1`'s thre... | true |
24639cd41f83c2339ae0bce6af0162bd4addeec2 | Rust | danleechina/Leetcode | /Rust_Sol/src/archive1/s318.rs | UTF-8 | 942 | 3.125 | 3 | [] | no_license | struct Solution {}
use std::cmp::max;
impl Solution {
pub fn max_product(words: Vec<String>) -> i32 {
let mut bit_words: Vec<i32> = vec![0; words.len()];
for (position, word) in words.iter().enumerate() {
let num_words = word.as_bytes().iter().map(|item| {
return item - b'a';
});
fo... | true |
173df9a3b4af0d042ca7f834da7f2210a00f189b | Rust | jethrosun/NetBricks | /framework/src/operators/filter_batch.rs | UTF-8 | 3,112 | 2.59375 | 3 | [
"ISC"
] | permissive | use super::act::Act;
use super::iterator::*;
use super::packet_batch::PacketBatch;
use super::Batch;
use crate::common::*;
use crate::headers::EndOffset;
use crate::interface::Packet;
use crate::interface::PacketTx;
/// Filter function.
// TODO:doc
pub type FilterFn<T, M> = Box<dyn FnMut(&Packet<T, M>) -> bool + Send>... | true |
c2cec8f221165b580b0ba7f217439a06f7be947a | Rust | mnts26/aws-sdk-rust | /sdk/efs/src/input.rs | UTF-8 | 244,455 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
use std::fmt::Write;
/// See [`CreateAccessPointInput`](crate::input::CreateAccessPointInput)
pub mod create_access_point_input {
/// A builder for [`CreateAccessPointInput`](crate::input::CreateAccessPointInput)
#[non_exhaustive]
... | true |
0d0f07d684a7c1c1ba049af19db7d8edaf21e6fb | Rust | kumojan/rnc | /src/parse/mod.rs | UTF-8 | 60,936 | 3.109375 | 3 | [] | no_license | use crate::ctype::*;
use crate::tokenize::*;
use node::*;
use std::fmt;
use std::rc::Rc;
pub mod node;
#[derive(Debug, Default)]
pub struct ParseError {
pub pos: usize,
pub msg: String,
}
impl ParseError {
fn new<S: Into<String>>(pos: usize, msg: S) -> ParseError {
ParseError {
pos,
... | true |
95492c6dd156f47f1bfd0d5d10abbabe8fc44277 | Rust | mijinko17/rust_snippets | /src/divisor.rs | UTF-8 | 445 | 2.890625 | 3 | [] | no_license | use cargo_snippet::snippet;
#[snippet("divisor")]
fn divisor<T: num::PrimInt>(a: T) -> Vec<T> {
let div_small = num::iter::range_inclusive(T::one(), a)
.take_while(|&i| i * i <= a)
.filter(|&i| T::is_zero(&(a % i)));
let div_large = num::iter::range_inclusive(T::one(), a)
.take_while(|&... | true |
2be4bf394b41cc2d5a9bdda27f55e7a8d620aa08 | Rust | adtennant/pyxel | /src/pyxel.rs | UTF-8 | 17,288 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::{
deserialization::{
deserialize_as_degrees, deserialize_as_milliseconds, deserialize_map_as_vec,
deserialize_multipliers,
},
error::PyxelError,
};
use derivative::Derivative;
use semver::Version;
use serde::Deserialize;
use std::{collections::BTreeMap, time::Duration};
/// An R... | true |
68432fc446a2956b9e0123adf958dd66356917a6 | Rust | Swordelf2/shifter | /src/loading/mod.rs | UTF-8 | 3,289 | 2.796875 | 3 | [] | no_license | //! Loading state is responsible for loading assets, and transitioning into the next state
//! upon completion
use std::collections::HashMap;
use crate::asset;
use crate::game;
use crate::state::AppState;
use bevy::asset::LoadState;
use bevy::prelude::*;
use strum::{EnumCount, IntoEnumIterator};
/// Resource, used ... | true |
9f57fe5ea1d4910bdef431eae79a761c7fb55a7c | Rust | davidpdrsn/diesel-factories | /diesel-factories/src/lib.rs | UTF-8 | 15,873 | 3.90625 | 4 | [
"MIT"
] | permissive | //! This is an implementation the test factory pattern made to work with [Diesel][].
//!
//! [Diesel]: https://diesel.rs
//!
//! Example usage:
//!
//! ```
//! #[macro_use]
//! extern crate diesel;
//!
//! use diesel_factories::{Association, Factory};
//! use diesel::{pg::PgConnection, prelude::*};
//!
//! // Tell Dies... | true |
a886236c0617f48481ad2494cabe3f0cc2983e8f | Rust | TyOverby/snoot | /src/lib.rs | UTF-8 | 1,379 | 2.828125 | 3 | [] | no_license | extern crate tendril;
extern crate regex;
extern crate itertools;
#[macro_use]
extern crate serde_json;
#[cfg(test)]
#[macro_use]
extern crate serde_derive;
extern crate serde;
pub mod token;
pub mod parse;
#[macro_use]
pub mod diagnostic;
pub mod serde_serialization;
mod sexpr;
pub use sexpr::Sexpr;
/// The result ... | true |
9cf178d28553fb7854349dfd7d0b5da83394beb1 | Rust | canpok1/atcoder-rust | /contests/abc183/src/bin/c.rs | UTF-8 | 1,882 | 3.265625 | 3 | [] | no_license | use std::collections::HashSet;
fn read_line() -> String {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().to_owned()
}
fn main() {
let stdin = read_line();
let mut iter = stdin.split_whitespace();
let n = iter.next().unwrap().parse().unwrap();
... | true |
341fd22d0dfa9f3ff46f380f5b3bc121473be96e | Rust | ZaoIsmael/football | /src/people/player/mailbox.rs | UTF-8 | 264 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Debug)]
pub enum PlayerMessage {
Greeting,
}
#[derive(Debug)]
pub struct PlayerMailbox {
messages: Vec<PlayerMessage>,
}
impl PlayerMailbox {
pub fn new() -> Self {
PlayerMailbox {
messages: Vec::new(),
}
}
}
| true |
850460f265a77252d42924de628e2fa3ff3de44a | Rust | rustbunker/dur | /src/config/parser.rs | UTF-8 | 379 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::{fs::File, io::Read};
use crate::Config;
impl Config {
pub fn from_path(path: String) -> Self {
let mut file = File::open(path).unwrap();
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
let config: Config = toml::from_str(&contents).unwrap();... | true |
f81b5f0859bfe495d1fd7c1c69e2f4f8d5033817 | Rust | R1tschY/chassis | /dyn-chassis/examples/greeter.rs | UTF-8 | 1,191 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use dyn_chassis::{module, BindAnnotation, Injector};
use std::error::Error;
use std::sync::Arc;
#[derive(Debug)]
struct Message;
impl BindAnnotation for Message {}
#[derive(Debug)]
struct Count;
impl BindAnnotation for Count {}
struct Greeter {
message: String,
count: i32,
}
impl Greeter {
pub fn new(me... | true |
4e9e14068a5443264e54ae1f16873df3d6969d80 | Rust | cda-group/arc | /arc-runtime/src/data/vectors.rs | UTF-8 | 3,595 | 2.671875 | 3 | [] | no_license | use crate::prelude::*;
pub mod sharable {
use crate::prelude::*;
#[derive(
Clone, From, Deref, DerefMut, Finalize, Collectable, Debug, Send, Sync, Unpin, Trace,
)]
#[from(forward)]
pub struct Vec<T: Sharable>(pub Gc<ConcreteVec<T>>);
pub type ConcreteVec<T> = comet::alloc::vector::Vec... | true |
d5da75a6671bf15f6f494766745d802adaa2d9db | Rust | marco-c/gecko-dev-wordified | /third_party/rust/tokio/src/io/util/async_buf_read_ext.rs | UTF-8 | 12,443 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
crate
:
:
io
:
:
util
:
:
fill_buf
:
:
{
fill_buf
FillBuf
}
;
use
crate
:
:
io
:
:
util
:
:
lines
:
:
{
lines
Lines
}
;
use
crate
:
:
io
:
:
util
:
:
read_line
:
:
{
read_line
ReadLine
}
;
use
crate
:
:
io
:
:
util
:
:
read_until
:
:
{
read_until
ReadUntil
}
;
use
crate
:
:
io
:
:
util
:
:
split
:
:
{
split
Split
}... | true |
a455bc72c537883752352858e38b6c5716f9fa63 | Rust | input-output-hk/jormungandr | /testing/jormungandr-automation/src/jormungandr/rest/settings.rs | UTF-8 | 429 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use reqwest::Certificate;
#[derive(Debug, Clone, Default)]
pub struct RestSettings {
pub enable_debug: bool,
pub use_https: bool,
pub certificate: Option<Certificate>,
pub cors: Option<String>,
}
impl RestSettings {
pub fn new_use_https() -> Self {
RestSettings {
enable_debug: ... | true |
15919f90a12d091bee60fc1dde0e27ff6f831863 | Rust | FauxFaux/wcwidth.rs | /gen/trie.rs | UTF-8 | 6,973 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::hash_map::DefaultHasher as DHasher;
use std::hash::Hasher;
use std::io::prelude::*;
const BLOCK_SIZE: usize = 64;
const BLOCK_OFFSET: usize = 2;
const ROOT_BLOCK_OFFSET: usize = 3;
#[derive(Clone)]
struct Builder {
valu... | true |
75035c251acaf0a0b00e8c07b838729609e101ad | Rust | przygienda/edo | /src/parse.rs | UTF-8 | 5,486 | 3.375 | 3 | [
"MIT"
] | permissive | use std::str;
use std::borrow::Cow;
use nom::{alphanumeric, IResult};
use error::EdoError;
#[derive(Debug, PartialEq)]
pub enum Expression<'a> {
Function {
name: Cow<'a, str>,
arguments: Vec<Cow<'a, str>>,
},
Literal(Cow<'a, str>),
}
// Parse a list of arguments
// TODO: allow non alphan... | true |
6f0b81f73ba64adbcc837dcf832dfbd1382e3711 | Rust | coreh/universe | /src/shader.rs | UTF-8 | 4,094 | 2.875 | 3 | [] | no_license | use std;
use std::fs::File;
use std::io::prelude::*;
use std::fmt::Write as FmtWrite;
use gl;
use gl::types::*;
use crate::error::Error;
pub enum Attribute {
Position = 0,
Normal = 1,
UV = 2,
}
pub enum Uniform {
ModelView = 0,
Projection = 1,
}
pub struct Shader {
pub(crate) program: GLuin... | true |
12aeefae4a7755acd742cc83d3bb365a2a3dd92e | Rust | dennis/hat | /hat-miflora/src/cmd_opts.rs | UTF-8 | 1,472 | 2.875 | 3 | [
"MIT"
] | permissive | use structopt::StructOpt;
#[derive(StructOpt)]
pub struct CmdOpts {
/// Output JSON
#[structopt(short, long)]
pub json: bool,
/// Don't show headers (ignored for JSON output)
#[structopt(short = "H", long)]
pub no_headers: bool,
#[structopt(subcommand)]
pub cmd: Command,
}
#[derive(S... | true |
339b1343a0e6ae6636baca676af83f4aa1f4877d | Rust | skerkewitz/advent_of_code_2020 | /src/main_day19.rs | UTF-8 | 3,700 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, VecDeque, HashSet};
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::iter::{FromIterator, Peekable};
use std::cmp::{max, min};
use std::mem;
use std::env::join_paths;
use tokio::stream::StreamExt;
use regex::Regex;
mod test;
fn read_lines_from_file(filename: &str) -> std:... | true |
3f77b9f99ef5214375d09263c2f08cebbd6e008b | Rust | isso0424/TaskManagerRust | /src/command/update.rs | UTF-8 | 3,546 | 3.15625 | 3 | [] | no_license | use crate::args::parse_arg;
use crate::command::types::label::Labels;
use crate::command::types::task::{Task, Tasks};
fn regeneration_task(
title: String,
args: Vec<String>,
mut tasks: Tasks,
labels: Labels,
) -> Result<Tasks, String> {
if !tasks.content.iter().any(|task| task.title == title) {
... | true |
75e710f1920854921fce5604451dfc713032cc92 | Rust | canndrew/future-utils | /src/bi_channel.rs | UTF-8 | 2,383 | 3 | 3 | [] | no_license | use futures::{Stream, Sink, Async, AsyncSink};
use futures::sync::mpsc::SendError;
use void::Void;
use mpsc::{self, UnboundedSender, UnboundedReceiver};
#[derive(Debug)]
pub struct UnboundedBiChannel<T> {
tx: UnboundedSender<T>,
rx: UnboundedReceiver<T>,
}
impl<T> UnboundedBiChannel<T> {
pub fn unbounded_... | true |
0eb07122a720933845125f574535c539a18b59cf | Rust | nanocryk/arquery | /tests/xml_document_test.rs | UTF-8 | 736 | 2.859375 | 3 | [
"MIT"
] | permissive | use arquery::Document;
#[test]
fn it_captures_the_correct_number_of_elements() {
let result = Document::new_from_xml_string(
r#"
<?xml version="1.0" encoding="UTF-8"?>
<body>
<one/>
<two/>
<three/>
</body>
"#,
);
assert!(result.is_ok());
}
#[test]
fn it_can_be_created_from_a_file() {
le... | true |
b336da005b20801e079966f644f99de645753227 | Rust | robertkuhar/TheRustProgrammingLanguage | /projects/rectangles/src/main.rs | UTF-8 | 3,192 | 3.9375 | 4 | [] | no_license | use std::fmt;
fn main() {
// Listing 5-8 is a 2 argument function
let width1 = 30;
let height1 = 50;
println!(
"area_5_8(width: {}, height: {}) => {}",
width1,
height1,
area_5_8(width1, height1)
);
// Listing 5-9 leverages tuples in the function call
// Note... | true |
7c07f5b18fab91207cff9a39a604e62e913346f5 | Rust | eduardossampaio/rust-study | /lifetimes/src/main.rs | UTF-8 | 907 | 3.8125 | 4 | [] | no_license | struct ImportantExcerpt<'a> {
part: &'a str
}
fn main() {
println!("Hello, world!");
let r;
// {
let x = 5;
r = &x;
// }
println!("R is: {}", r);
let string1 = String::from("abcd");
// {
let string2 = "xyz";
let result = longest(string1.as_str(), string... | true |
246896694c3b36e139c0af6507973a82407ed213 | Rust | BaZzz01010101/ReflaxManRs | /src/math/tests/clamp.rs | UTF-8 | 307 | 3.015625 | 3 | [] | no_license | use super::clamp;
#[test]
fn clamp_f32() {
assert_eq!(clamp(1.5, -2.0, 1.0), 1.0);
assert_eq!(clamp(-3.5, -2.0, 1.0), -2.0);
assert_eq!(clamp(0.5, -2.0, 1.0), 0.5);
}
#[test]
fn clamp_i32() {
assert_eq!(clamp(12, -3, 8), 8);
assert_eq!(clamp(-5, -3, 8), -3);
assert_eq!(clamp(2, -3, 8), 2);
}
| true |
49167962b8ab9c8d3971a177ff624e1b5ffb254d | Rust | maxal9999/wow_wiki_bot | /src/config.rs | UTF-8 | 1,070 | 3.0625 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use url::Url;
/// Struct for storage params from config.toml
#[derive(Deserialize)]
pub struct Config {
//wow_wiki_sites: Vec<String>,
telegram_token: String,
telegram_endpoint: String,
pub timeout: u64
}
impl Config {
/// Constructo... | true |
17d5765efa3e15f56789417a70fb0c37ebab875b | Rust | SpenserHaddad/cah-rust | /src/game/cards/deck.rs | UTF-8 | 3,371 | 3.71875 | 4 | [
"MIT"
] | permissive | use std::fmt::Debug;
use rand::seq::SliceRandom;
#[derive(Debug, Clone, PartialEq)]
pub enum DeckError {
NoCards,
InvalidCards,
}
#[derive(Debug)]
pub struct Deck<T>
where
T: Debug,
{
draw_pile: Vec<T>,
active_cards: Vec<T>,
discard_pile: Vec<T>,
deck_size: usize,
}
impl<T> Deck<T>
where... | true |
c39456949f4413fb5f5cf31cf4cf8b1f2f6ff25c | Rust | akimash/abc | /80/c.rs | UTF-8 | 1,223 | 3.09375 | 3 | [] | no_license | use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
... | true |
a56b295fef23a275c1bb4a59cffea9a9df26d630 | Rust | cleancoindev/dark-forest | /crates/df-types/src/planet/id.rs | UTF-8 | 4,476 | 3.03125 | 3 | [] | no_license | use crate::utils;
use derive_more::AsRef;
use ethers::types::U256;
use serde::{de, Deserialize, Serialize};
#[derive(
Default, Debug, Clone, Copy, AsRef, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash,
)]
#[as_ref]
/// Wrapper type around the planet id, created by the MIMC hash of the coords
pub stru... | true |
a3ca7ed331869fe7e2725c2052c6652aca988c02 | Rust | isgasho/shy | /src/ssh_config.rs | UTF-8 | 4,376 | 3.375 | 3 | [
"MIT"
] | permissive | use {
indexmap::IndexMap,
std::{env, fs, io},
};
pub type HostMap = IndexMap<String, String>;
/// For now just load the hostnames and their labels.
pub fn load_ssh_config(path: &str) -> io::Result<HostMap> {
parse_ssh_config(&fs::read_to_string(
path.replace('~', &env::var("HOME").expect("$HOME mu... | true |
5610a3ca3babf24e8a65928a25594ee301ab198f | Rust | SuperTails/rusty-nes | /src/config.rs | UTF-8 | 1,650 | 3.09375 | 3 | [] | no_license | use std::path::PathBuf;
use std::str::FromStr;
#[derive(Debug, Clone)]
pub struct Config {
pub rom_path: PathBuf,
pub verify: bool,
}
#[derive(Debug, Clone)]
pub struct ConfigParseError {
error: String,
}
#[derive(PartialEq)]
enum Flag {
Verify,
}
impl FromStr for Flag {
type Err = ConfigParseEr... | true |
cdd85a8c3f3c9b3ed7fcc466815ab1b5f53c6bef | Rust | Riey/tiny-md5-rs | /src/lib.rs | UTF-8 | 1,921 | 3 | 3 | [] | no_license | #![cfg_attr(test, feature(test))]
#[cfg(test)]
extern crate test;
mod state;
use std::io::Read;
pub fn hash(mut input: impl Read) -> [u8; 16] {
let mut state = state::MD5State::new();
loop {
match input.read(&mut state.buf[..]) {
Err(_) => {
return state.digest();
... | true |
8f1781fec1d7ae41036a4d7840b8e013c926779c | Rust | jakecraige/provisions | /src/data_source/asset.rs | UTF-8 | 1,296 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::fields::Field256;
use crate::proofs::AssetProof;
use crate::secp256k1::{point_mul, Point};
use crate::serialization::Serialize;
use num_bigint::BigUint;
use rocksdb::DB;
pub type AssetData = (Option<Field256>, Point, BigUint);
pub trait AssetDataSource {
/// Retrieve next asset to generate proof for
... | true |
6af72d1719720e3db2630d3814b3fe1678c28c16 | Rust | jeffujioka/rust_wizardry | /prjs/data_types/src/strings.rs | UTF-8 | 1,269 | 3.921875 | 4 | [] | no_license | pub fn print_strings()
{
// UTF-8
let mut s1: &str = "Jefferson M Fujioka";
// s = "new value"; // it doesn't work
// let ch = s[0]; // it also doesn't work
for c in s1.chars() {
print!("{}", c);
}
println!("\nReverse...");
for c in s1.chars().rev() {
print!("{}", c);
... | true |
2d22e119d6d330d317d81daae86e4fe74ef09502 | Rust | graphprotocol/graph-node | /chain/cosmos/src/trigger.rs | UTF-8 | 12,870 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::{cmp::Ordering, sync::Arc};
use graph::blockchain::{Block, BlockHash, MappingTriggerTrait, TriggerData};
use graph::cheap_clone::CheapClone;
use graph::prelude::{BlockNumber, Error};
use graph::runtime::HostExportError;
use graph::runtime::{asc_new, gas::GasCounter, AscHeap, AscPtr};
use graph_runtime_wasm::m... | true |
7373a7f7fb4073e34b2ee7817ee9d9a194830240 | Rust | martinaAgata/21C1-Rust-eze | /src/commands/server/config_get.rs | UTF-8 | 2,149 | 2.84375 | 3 | [] | no_license | use crate::tcp_protocol::server_redis_attributes::ServerRedisAttributes;
use crate::{
commands::{check_empty, Runnable},
native_types::{ErrorStruct, RArray, RedisType},
vec_strings,
};
pub struct ConfigGet;
impl Runnable<ServerRedisAttributes> for ConfigGet {
/// The CONFIG GET command is used to read... | true |
47274aca6114c07a5243091b85b7909ca77f4a74 | Rust | nikomatsakis/rust | /src/libcore/result.rs | UTF-8 | 1,921 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"bzip2-1.0.6",
"BSD-1-Clause"
] | permissive | /*
Module: result
A type representing either success or failure
*/
/* Section: Types */
/*
Tag: t
The result type
*/
tag t<T, U> {
/*
Variant: ok
Contains the result value
*/
ok(T);
/*
Variant: err
Contains the error value
*/
err(U);
}
/* Section: Operations */
/*
Functio... | true |
1c61352236e903c5d0a71d581c82ec70c783398e | Rust | Nuc1eoN/SteamHelper-rs | /crates/steam-crypto/src/lib.rs | UTF-8 | 2,315 | 3.015625 | 3 | [
"MIT"
] | permissive | //! Steam System uses RSA to encrypt messages
//! If we want to emulate its behavior we
//! need to encrypt our stuff with the leaked
//! public key
//!
//! Direct Port of
//! https://github.com/DoctorMcKay/node-steam-crypto
#[allow(unused_imports)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate lazy... | true |
553ba3d98d267212b47316fdca3eb8f2dac75b33 | Rust | yubaoquan/minigrep | /other/src/main.rs | UTF-8 | 1,601 | 3.796875 | 4 | [] | no_license | use std::cmp::Ordering;
#[derive(Eq, Debug)]
struct Person {
pub name: &'static str,
pub age: isize,
}
impl Person {
pub fn new(name: &'static str, age: isize) -> Person {
Person { name, age }
}
pub fn hi(&self) {
println!("Hello, I am {}, {} years old", &self.name, &self.age);
... | true |
5d0f1162d617c200704334756055a9047841971f | Rust | art-in/meteos | /notifications/src/utils.rs | UTF-8 | 1,386 | 3.625 | 4 | [] | no_license | pub fn beautiful_string_join(strings: Vec<&str>) -> String {
if strings.is_empty() {
String::new()
} else if strings.len() == 1 {
strings[0].into()
} else if strings.len() == 2 {
strings.join(" and ")
} else {
let all_except_last = &strings[0..strings.len() - 1];
... | true |
41731202d63718e21c6a25f46a2b99162f55f703 | Rust | senior-sigan/fantasy-asm | /src/machine.rs | UTF-8 | 5,175 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::instructions::{exec, Instruction};
use crate::machine::ConstOperand::*;
use crate::machine::MutOperand::*;
use crate::machine::Register::*;
#[derive(Hash, Eq, PartialEq, Copy, Clone)]
pub enum Register {
// General purposes register
R0,
R1,
R2,
R3,
R4,... | true |
dfeaa1a372f45b67d6d21b5d4272263d2993d92d | Rust | oraisa/paperman | /src/app.rs | UTF-8 | 5,727 | 2.71875 | 3 | [] | no_license | use crate::commands::*;
use crate::rofi_picker;
use crate::string_cleaner;
use crate::filter;
use crate::bibtex;
use json;
use std::path::PathBuf;
use std::io::Read;
use structopt::clap;
use structopt::StructOpt;
pub struct App {
db: json::JsonValue,
selection: json::JsonValue,
}
impl App {
fn new() -> Ap... | true |
2397d0c3cb11f3752ddbbd102a30c4d8536a04a8 | Rust | Kasama/NovaROMarketBot | /src/telegram.rs | UTF-8 | 3,053 | 2.6875 | 3 | [] | no_license | use novaro_bot::web::{get_ids_by_name, get_market_entries};
use std::error::Error;
use futures::prelude::*;
use telegram_bot::{
Api,
EditMessageText,
InlineKeyboardButton,
InlineKeyboardMarkup,
Message,
MessageKind,
UpdateKind,
SendMessage
};
use tokio_core::reactor::Core;
pub fn run_b... | true |
8131125c635907807bcfa62cbc9f86cce068e3fa | Rust | layog/advent-of-code | /2020/1_1.rs | UTF-8 | 531 | 2.953125 | 3 | [] | no_license | use std::collections::HashSet;
use std::io::Read;
fn main() -> std::io::Result<()> {
let mut buffer = String::new();
std::io::stdin().read_to_string(&mut buffer)?;
let nums: Vec<i32> = buffer
.trim_end()
.split('\n')
.map(|x| x.parse().unwrap())
.collect();
let mut seen ... | true |
dc040f34e84c0911351e33177b3ec116f431af46 | Rust | tommyettinger/heh | /src/rng/xoroshiro128simd.rs | UTF-8 | 7,056 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use rand_core::{Error, RngCore, SeedableRng};
use rand_core::block::{BlockRngCore, BlockRng};
use faster::Transmute;
use faster::vecs::u64x4;
use byteorder::{LittleEndian, ByteOrder};
use super::SplitMix64;
/// A xoroshiro128+ random number generator using SIMD to generate 4 `u64` at a time.
///
/// The xoroshiro128+... | true |
23ede3aa1657bafe09f66f3a64d390a1ab8b85e3 | Rust | dustlang/dustfmt | /tests/source/lhs-to-rhs-between-comments/assignment.rs | UTF-8 | 2,660 | 2.984375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // "=" Assignemnt
fn main () {
let var = first;
var = second;
}
fn main () {
let var = /* Block comment */ first;
var = /* Block comment */ second;
}
fn main () {
let var = // Line comment
first;
var = // Line comment
second;
}
fn main () {
let var = /... | true |
dce090e7e63cfcdf7b6f2ff3558e5057783f02b1 | Rust | chuck-flowers/semverify | /src/consts.rs | UTF-8 | 333 | 2.78125 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use serde::Serialize;
use syn::ItemConst;
/// Describes a Rust const
#[derive(Deserialize, Serialize)]
pub struct ConstMetadata {
name: String,
}
impl From<ItemConst> for ConstMetadata {
fn from(src: syn::ItemConst) -> Self {
let name = src.ident.to_string();
Self { na... | true |
404f881008a57f4db9a62074349d02a5a63f2642 | Rust | ModPhoenix/job-interview | /server/src/questions/schema.rs | UTF-8 | 1,601 | 2.75 | 3 | [] | no_license | use async_graphql::guard::Guard;
use async_graphql::*;
use async_graphql::{Context, Error, Object};
use chrono::NaiveDateTime;
use crate::{
auth::models::{Role, RoleGuard},
users::models::User,
};
use super::models::Question;
#[Object]
impl Question {
async fn id(&self) -> i32 {
self.id
}
... | true |
fb30301dc92b03dcbaef2ef7b5f6f6bf568ec5f7 | Rust | chongyi/inspirer-rs | /inspirer-content/src/util/hash.rs | UTF-8 | 849 | 2.796875 | 3 | [
"MIT"
] | permissive | use argon2::{
password_hash::{rand_core::OsRng, PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
Argon2,
};
use sha2::{Digest, Sha256};
use crate::error::InspirerContentResult;
pub fn sha256(msg: &[u8]) -> Vec<u8> {
let mut hasher = Sha256::new();
hasher.update(msg);
hasher.finalize()... | true |
8b66f9939f6f9d272893b825ddd761c1162a736f | Rust | IlyaBizyaev/rust-experiments | /algorithms/strings/substring-cnt-automaton.rs | UTF-8 | 3,481 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::io;
use std::fs::File;
use std::io::prelude::*;
use std::collections::BTreeMap;
/* Automaton state */
#[derive(Clone)]
struct State {
len: usize,
link: i32,
next: BTreeMap<u8, usize>
}
impl State {
fn new() -> Self {
Self {
len: 0,
link: 0,
next: BT... | true |
5e55d3b0357e4350877fa71b5fb6649594c14187 | Rust | coriolinus/adventofcode-2016 | /day11/src/floor.rs | UTF-8 | 8,246 | 3.40625 | 3 | [] | no_license | use std::{collections::HashSet, fmt};
use crate::{Device, Element, Gadget};
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct Floor {
generators: HashSet<Element>,
microchips: HashSet<Element>,
}
impl Floor {
/// A floor is safe if there are no generators or every microchip is accompanied by its... | true |
c24b062d9019ed5cf494c403cd1c32900a134c93 | Rust | jbfp/aoc2020 | /src/day02/mod.rs | UTF-8 | 1,496 | 2.859375 | 3 | [] | no_license | use std::println;
use regex::Regex;
static FILE: &str = include_str!("../inputs/2.txt");
lazy_static! {
static ref REGEX: Regex = Regex::new("^(\\d+)-(\\d+) (\\w): (\\w+)$").unwrap();
}
pub(crate) fn part1() {
println!("day 2 part 1");
let num_valid = FILE
.lines()
.filter(|s| {
... | true |
8ee330198c82f5dc5afe1dec5528bb68559ec9d0 | Rust | fugue-re/fuguex-core | /fuguex-hooks/src/types.rs | UTF-8 | 987 | 2.703125 | 3 | [
"MIT"
] | permissive | use fugue::ir::il::Location;
use thiserror::Error;
pub enum HookAction<R> {
Pass,
Halt(R),
}
pub enum HookCBranchAction<R> {
Pass,
Flip,
Halt(R),
}
pub enum HookCallAction<R> {
Pass,
Skip,
Halt(R),
}
pub enum HookStepAction<R> {
Branch(Location),
Pass,
Halt(R),
}
pub str... | true |
98062cd1eec9d0decb53bdc10814f3b84684430d | Rust | timebackzhou/kas | /src/data.rs | UTF-8 | 5,904 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | // 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 in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Data types
use std::convert::TryFrom;
use std::fmt;
us... | true |
a35c20252bb74092da364ab80927d7218c589eb1 | Rust | EFanZh/LeetCode | /src/problem_0970_powerful_integers/mod.rs | UTF-8 | 755 | 2.9375 | 3 | [] | no_license | pub mod brute_force;
pub trait Solution {
fn powerful_integers(x: i32, y: i32, bound: i32) -> Vec<i32>;
}
#[cfg(test)]
mod tests {
use super::Solution;
use crate::test_utilities;
pub fn run<S: Solution>() {
let test_cases = [
((2, 3, 10), &[2, 3, 4, 5, 7, 9, 10] as &[_]),
... | true |
a90728c18effa8609ac03acc4d714d2fb4299f0a | Rust | Axect/Euler | /Rust/euler/src/problems/p019.rs | UTF-8 | 2,858 | 3.609375 | 4 | [] | no_license | use self::Day::*;
use self::Month::*;
pub fn ans() {
let mut date = Date {
year: 1900,
month: January,
day: Monday,
num: 1,
};
while date.year == 1900 {
date.next();
}
let mut count_sunday = 0usize;
loop {
date.next();
//println!(
... | true |
fe4d8ba890f7ce889b5babc9789bedf6dd05047f | Rust | jibby0/bnuuy | /src/api/v1/dog.rs | UTF-8 | 896 | 2.84375 | 3 | [] | no_license | use crate::api::v1::{Resp, RespErr};
use crate::db::{dogs, DbConn};
use rocket::{http::Status, response::content};
use std::io::prelude::Read;
use std::fs;
#[get("/dog")]
pub fn dog(conn: DbConn) -> Resp<content::Html<String>> {
let path = match dogs::get_random(&conn) {
Ok(dog) => dog.path,
Err(... | true |
ce2e198d95d2b77ecc579e1ccbcef3726b130e1e | Rust | Zireael07/Rust-HTML-roguelike | /src/lispy/parser.rs | UTF-8 | 7,189 | 3.453125 | 3 | [] | no_license | //based almost 100% on https://github.com/Geal/nom/blob/master/examples/s_expression.rs
//! In this example we build an [S-expression](https://en.wikipedia.org/wiki/S-expression)
//! parser and tiny [lisp](https://en.wikipedia.org/wiki/Lisp_(programming_language)) interpreter.
//! Lisp is a simple type of language mad... | true |
e5c705dfd3f15eda5cc06781f4af028d21b798eb | Rust | desidia26/dailycodingproblem | /may2021/src/bin/5_23_21.rs | UTF-8 | 760 | 3.734375 | 4 | [] | no_license | // Good morning! Here's your coding interview problem for today.
// This problem was recently asked by Google.
// Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
// For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
// Bonus: Can you do t... | true |
7ac8f482c47dacba135ba1e2ecf205829890ff4e | Rust | nejucomo/sappho-on-rust | /src/value/number.rs | UTF-8 | 4,120 | 3.75 | 4 | [] | no_license | use num::{BigInt, FromPrimitive, Zero};
use std::fmt::{Debug, Display, Error, Formatter};
use std::ops::Neg;
#[derive(Clone)]
pub struct Number {
i: BigInt,
point: i32,
}
impl Number {
pub fn new(mut i: BigInt, mut point: i32) -> Number {
let ten: BigInt = BigInt::from_i64(10).unwrap();
le... | true |
8f0c500a4f84312057b83e8a23c0da05c1338072 | Rust | Muqito/lark | /components/lark-parser/src/syntax/expression/expr0_base.rs | UTF-8 | 3,791 | 2.78125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::parser::Parser;
use crate::syntax::delimited::Delimited;
use crate::syntax::expression::block::Block;
use crate::syntax::expression::literal::Literal;
use crate::syntax::expression::scope::ExpressionScope;
use crate::syntax::expression::ParsedExpression;
use crate::syntax::expression::{Expression, HirExpress... | true |
bd4b359fcbfa39d2546a5176adc73e10d84d4fad | Rust | holtgrewe/tell-tool | /tell-tool/src/main.rs | UTF-8 | 3,096 | 2.5625 | 3 | [] | no_license | // `error_chain!` can recurse deeply.
#![recursion_limit = "1024"]
// We are using `error-chain`.
#[macro_use]
extern crate error_chain;
// We are using the `clap` crate for command line argument parsing.
#[macro_use]
extern crate clap;
extern crate rayon;
// We are using the `slog` crate for logging.
#[macro_use]
... | true |
fe0822bac1f18833814b03ad85b9776aa5d2a68b | Rust | lakwet/voracious_sort | /src/sorts/boolean_sort.rs | UTF-8 | 1,719 | 3.078125 | 3 | [
"MIT"
] | permissive | // use super::super::{RadixKey, Radixable};
#[inline]
fn boolean_sort_aux(arr: &mut [bool], shift: usize, count: usize, value: bool) {
let quotient = count / 4;
let remainder = count % 4;
for q in 0..quotient {
unsafe {
let i = shift + (q * 4);
*arr.get_unchecked_mut(i) = va... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.