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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
defbb62f61c2204b52f38f3a8d79c274546a74a9 | Rust | cyrusmetcalf/pid_example | /src/pid/mod.rs | UTF-8 | 3,718 | 3.359375 | 3 | [
"MIT"
] | permissive | use core::time::Duration;
#[derive(Debug, PartialEq)]
pub struct Pid {
p_coefficient: f32,
i_coefficient: f32,
d_coefficient: f32,
last_iterm: f32,
last_error: f32,
}
impl Pid {
pub fn new(p_coefficient: f32, i_coefficient: f32, d_coefficient: f32) -> Pid {
Pid {
p_coeffici... | true |
10a0a4f8fe558a4bc836333443ed86f5ec736cca | Rust | gautammohan/advent2020 | /src/day2.rs | UTF-8 | 3,227 | 3.375 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs;
pub fn day2() {
let s = fs::read_to_string("inputs/day2.txt").expect("file not found");
let items : Vec<_> = s.lines().map(parse_line).collect();
println!("day 2 part 1: {}", get_all_valid_passwords(items));
let items2 : Vec<_> = s.lines().map(parse_line2).... | true |
ea9eeb4e7a0e2dda6d6088404b1bf6ad2d43e27b | Rust | gaertn/rust-lp | /src/data/number_types/rational/big/mod.rs | UTF-8 | 1,137 | 3.046875 | 3 | [
"MIT"
] | permissive | //! # An arbitrary precision rational type
//!
//! At the moment, this is just wrapping the `num::BigRational` type, following the newtype pattern.
//! This is needed because some of the impl's in this module are not provided by `num`. Methods on
//! this type can be modified and specialized as needed.
use std::fmt::{D... | true |
221a0c2d59997d65aa5809473720315a097c3186 | Rust | FoamCactus/rust-rsql | /src/comparison.rs | UTF-8 | 911 | 2.890625 | 3 | [] | no_license | use crate::value::Value;
use crate::selector::Selector;
use crate::comparison_operator::ComparisonOperators;
use crate::lex_item::LexItem;
use crate::{Parseable,ParseError};
use std::iter::Peekable;
use std::slice::Iter;
#[derive(Debug, Clone)]
pub struct Comparison {
selector: Selector,
comp: ComparisonOperato... | true |
908fdeb84bbd79881df3ee6d6a1c2413746d08eb | Rust | RedlineTriad/tanks | /src/systems/tank.rs | UTF-8 | 1,017 | 2.75 | 3 | [] | no_license | use bevy::{
core::Time,
input::Input,
math::Quat,
prelude::{KeyCode, Query, Res, Transform},
};
use crate::components::Tank;
pub fn tank_movement(
time: Res<Time>,
keyboard_input: Res<Input<KeyCode>>,
mut query: Query<(&Tank, &mut Transform)>,
) {
for (tank, mut transform) in query.ite... | true |
54115bc2bfa006c2217d7907f8ee911fb44e3fcf | Rust | austinjones/lifeline-rs | /src/channel/lifeline.rs | UTF-8 | 1,177 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::error::SendError;
use async_trait::async_trait;
use std::fmt::Debug;
impl<T: Debug> SendError<T> {
pub fn take_message(self) -> Option<T> {
match self {
SendError::Return(value) => Some(value),
SendError::Closed => None,
}
}
}
/// The sender half of an asynch... | true |
82c1a2e91858d4d903fccbea7185df36964bcb71 | Rust | pombredanne/flatdata | /flatdata-rs/lib/src/archive.rs | UTF-8 | 15,513 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | //! This module contains traits and macros that are used by generated code to
//! define flatdata's structs, archives and resources.
//!
//! # Archive
//!
//! A flatdata archive is introduced by `define_archive`. It defines two types
//! `ArchiveName` and `ArchiveNameBuilder` for reading resp. writing data.
use crate:... | true |
5d428d6967d9bb360f0d8f0e7accb5f960580553 | Rust | nwn/Advent-of-Code-2017 | /src/02b.rs | UTF-8 | 814 | 3.359375 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::cmp::PartialOrd;
fn minmax<T: PartialOrd>(a: T, b: T) -> (T,T) {
if a <= b {
(a,b)
} else {
(b,a)
}
}
fn main() {
let stdin = io::stdin();
let lines = stdin.lock().lines();
let sum = lines.map(|line| {
let line = line.unwra... | true |
de25a2d643fd13c6e0309d962b1fa786ac30d77a | Rust | bytesonus/juno | /src/models/juno_module.rs | UTF-8 | 4,863 | 2.546875 | 3 | [] | no_license | use crate::{constants, models::Module, service::data_handler};
use juno::{models::Value, JunoModuleImpl};
use std::{collections::HashMap, sync::Arc};
use async_std::task;
use async_trait::async_trait;
use futures::{
channel::mpsc::{UnboundedReceiver, UnboundedSender},
StreamExt,
};
use futures_util::sink::SinkExt;
... | true |
18aa195c702233413b093a73bc423c2cdd646c7a | Rust | RyanMeulenkamp/solplan-rust | /src/model/roof.rs | UTF-8 | 1,875 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use druid::{Data, Lens};
use crate::model::boundary::Boundary;
use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, PartialEq, PartialOrd, Data, Lens, Serialize, Deserialize)]
pub struct Roof {
ridge: f64,
eaves: f64,
height: f64,
}
impl Eq for Roof {
}
impl Roof {
pub const fn new(ridge_width... | true |
849b61319e59b695b2bfa1aeea2d8d5a13c88104 | Rust | AlterionX/totality-rs | /totality-render/src/buffers.rs | UTF-8 | 4,770 | 2.5625 | 3 | [] | no_license | use super::hal::{
adapter::MemoryTypeId,
buffer::Usage,
mapping::Writer,
memory::{Properties, Requirements},
pso::{EntryPoint, Specialization},
Adapter, Backend, Device, PhysicalDevice,
};
use std::{marker::PhantomData, mem::ManuallyDrop, sync::Arc};
#[allow(dead_code)]
use log::{debug, error, ... | true |
79e8d1ba0d73c90cb2b1d417860388e7c81f199f | Rust | ks3645/aoc2019 | /src/day2.rs | UTF-8 | 1,248 | 2.9375 | 3 | [] | no_license | use crate::utils;
use crate::utils::Part;
use crate::intcode_computer;
use std::collections::VecDeque;
pub fn solve(part: Part) -> i32 {
let mut input = String::new();
utils::read_input_to_string(&mut input, 2).unwrap();
let mut program: Vec<i32> = input
.trim()
.split(",")
.map(... | true |
3c262c2c42d647bf3b13165287ab173720b6dfea | Rust | daaku/sqlx-pg-migrate | /src/lib.rs | UTF-8 | 7,563 | 3.265625 | 3 | [
"MIT"
] | permissive | //! A library to run migrations on a PostgreSQL database using SQLx.
//!
//! Make a directory that contains your migrations. The library will run thru
//! all the files in sorted order. The suggested naming convention is
//! `000_first.sql`, `001_second.sql` and so on.
//!
//! The library:
//! 1. Will create the DB if ... | true |
a026622c6fdb07fc71d4b42e01cc1e4bff05f231 | Rust | simbahebinbo/actix-web-myworld-demo | /src/app/services/auth.rs | UTF-8 | 1,350 | 2.578125 | 3 | [] | no_license | use libreauth::pass::HashBuilder;
use validator::Validate;
use crate::{db::user::UserDB, error::Error, models::login::{LoginForm, LoginInfo}, utils::{hasher::{ PWD_SCHEME_VERSION, HASHER }, jwt::JWT}};
pub struct AuthSerivce;
impl AuthSerivce {
pub async fn login(&self, lf: &LoginForm) -> Result<Option<LoginInfo>... | true |
3ab6d2b354b3eda0d4ee7d21b88da5d636e37b16 | Rust | bkase/gameboy | /src/register.rs | UTF-8 | 5,846 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code)]
#[cfg(test)]
use proptest_derive::Arbitrary;
use register_kind::{RegisterKind16, RegisterKind8};
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(test, derive(Arbitrary))]
pub struct R16(pub u16);
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
... | true |
066d94e618627b3f443a885af1dd030bf8714841 | Rust | LordSentox/java-game | /java-game-derive/src/lib.rs | UTF-8 | 1,317 | 2.625 | 3 | [] | no_license | extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
use syn::{
export::Span, parse_macro_input, Attribute, DeriveInput, Ident, Lit, Meta, MetaNameValue
};
#[proc_macro_derive(Positionable, attributes(PosField))]
pub fn positionable_derive(input: TokenStream) -> TokenStream {
let input = pa... | true |
9bcaa35efe6cf8a5e3d3e16fd7db011421e743b0 | Rust | Jengamon/Return_RPG | /src/collision.rs | UTF-8 | 8,940 | 2.59375 | 3 | [] | no_license | // Based (read: ripped) off of resolv by @solarlune
use std::convert::AsRef;
use crate::generation::{GenerationalIndex, GenerationalIndexAllocator, GenerationalIndexArray};
use cgmath::{prelude::*, Vector2, Point2, dot};
#[derive(Clone, Debug)]
pub struct Shape {
x: f32,
y: f32,
tags: Vec<String>,
col... | true |
ab38dfc5a52b5b6aad4a48d86e27cac74ec6b881 | Rust | prz23/zinc | /zinc-vm/src/zvm/arguments/command/test.rs | UTF-8 | 1,528 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The Zinc virtual machine `test` subcommand.
//!
use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
use franklin_crypto::bellman::pairing::bn256::Bn256;
use zinc_vm::CircuitFacade;
use zinc_vm::ContractFacade;
use zinc_vm::LibraryFacade;
use crate::arguments::command::IExecutable;
use crate::err... | true |
f818098eb4cca3aa313ce6791bde76d39f60b55e | Rust | tomtau/rust-tsp | /src/stream.rs | UTF-8 | 5,801 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | // Stream consumer and producer for ABCI Messages
use integer_encoding::VarInt;
use messages::abci::*;
use mockstream::SharedMockStream;
use protobuf::Message;
use std::fmt::{self, Debug, Formatter};
use std::io;
use std::io::{Read, Write};
use std::net::TcpStream;
/// Wraps a stream for easier testing. Original code... | true |
1f09e7f624a85742d625e2dd1cce9def6269b4bc | Rust | alexbensimon/advent-of-code-2020 | /src/day_10/mod.rs | UTF-8 | 3,022 | 2.921875 | 3 | [] | no_license | use crate::utils::lines_from_file;
use std::time::Instant;
pub fn main() {
let start = Instant::now();
// assert_eq!(part_1_test_1(), 35);
// assert_eq!(part_1_test_2(), 220);
// println!("part_1 {:?}", part_1());
assert_eq!(part_2_test_1(), 8);
assert_eq!(part_2_test_2(), 19208);
println... | true |
0e8c14f57dcb57d8977e9e1a3542259d82b43a44 | Rust | nikomatsakis/rust | /src/test/run-pass/generic-bind-2.rs | UTF-8 | 184 | 2.8125 | 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 |
fn id<T: copy>(t: T) -> T { ret t; }
fn main() {
let t = {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7};
assert (t.f == 6);
let f0 = bind id(t);
assert (f0().f == 6);
}
| true |
72ce62041f2c13362917be7259d614a1a5b55300 | Rust | randomPoison/spatialos-sdk-rs | /spatialos-sdk/src/worker/component.rs | UTF-8 | 16,899 | 2.765625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::worker::internal::schema;
use spatialos_sdk_sys::worker::*;
use std::{collections::hash_map::HashMap, mem, os::raw, ptr, sync::Arc};
// Re-export inventory so generated code doesn't require the user to add inventory to their
// Cargo.toml
pub use inventory;
pub type ComponentId = Worker_ComponentId;
pub ty... | true |
e7a5a53ead33865066f198d8a62abf0baf5481df | Rust | phlopsi/allocator | /src/align128.rs | UTF-8 | 518 | 2.6875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[derive(Default)]
#[repr(align(128))]
pub struct Align128<T>(pub T);
impl<T> std::ops::Deref for Align128<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> std::ops::DerefMut for Align128<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}... | true |
3e2c255df6c67f595560577ebc34efb4299ac1bf | Rust | vegaluisjose/pest-playground | /stream/src/parser.rs | UTF-8 | 1,996 | 2.890625 | 3 | [] | no_license | use crate::ast::*;
use pest_consume::{match_nodes, Error, Parser};
use std::rc::Rc;
pub type Result<T> = std::result::Result<T, Error<Rule>>;
type Node<'i> = pest_consume::Node<'i, Rule, ()>;
#[derive(Parser)]
#[grammar = "stream.pest"]
struct StreamParser;
#[pest_consume::parser]
impl StreamParser {
fn EOI(_inp... | true |
53db89e53eb40d04e470b57c89dcad58162ad6cd | Rust | d-becker/spider | /spider_backend/src/iter/skip_last.rs | UTF-8 | 2,247 | 3.234375 | 3 | [] | no_license | use std::iter::{Fuse, FusedIterator};
pub trait SkipLastIterator: Iterator
where
Self: std::marker::Sized,
{
fn skip_last(self) -> SkipLast<Self>;
}
impl<I> SkipLastIterator for I
where
I: Iterator,
{
fn skip_last(self) -> SkipLast<I> {
SkipLast::new(self)
}
}
pub struct SkipLast<I>
where... | true |
5acdd5e2674b7d12c812bc1217cec6b858edc1d6 | Rust | Riey/ezemuera-trans | /src/lib.rs | UTF-8 | 11,805 | 2.609375 | 3 | [] | no_license | use encoding_rs::{EncoderResult, EUC_KR, SHIFT_JIS, UTF_16LE};
use eztrans_rs::{Container, EzTransLib};
use fxhash::FxHashMap;
use serde_derive::{Deserialize, Serialize};
use std::ffi::CStr;
use std::fs;
use std::path::Path;
use std::ptr::null_mut;
pub struct EzDictItem {
key: String,
value: String,
}
impl Ez... | true |
c13d25427a8e5adf08385d13d1293c185a64ea90 | Rust | GreenPix/behaviour-tree | /src/main.rs | UTF-8 | 967 | 2.515625 | 3 | [] | no_license | extern crate behaviour_tree;
use std::io::Read;
use std::collections::HashMap;
use behaviour_tree::tree::{BehaviourTreeNode,VisitResult};
use behaviour_tree::standard::{LeavesCollection};
fn main() {
println!("Starting process");
let mut stdin = std::io::stdin();
let mut string = String::new();
stdin... | true |
0b2d1dcaa2fc819216419104cb78963947f4cf82 | Rust | samgans/rust_algos | /src/sorting/heap_sort.rs | UTF-8 | 1,478 | 3.5625 | 4 | [] | no_license | use crate::data_structures::{BinHeap, MaxHeap, MinHeap};
fn return_sorted<R: Ord + PartialOrd, T: BinHeap<R>>(heap: &mut T) -> Vec<R> {
let mut sorted_vec: Vec<R> = vec!();
for _ in 0..heap.len() {
sorted_vec.push(heap.extract().unwrap())
}
sorted_vec
}
pub fn heap_sort<T: Ord + PartialOrd>(... | true |
a5a5cd33697aeaeb8c9eae800090990e0c154573 | Rust | TrionProg/stm32f30x-memory-map | /src/gpio/rb.rs | UTF-8 | 4,423 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[macro_export]
macro_rules! create_rb{
($address:expr) => (
# [ doc = "General-purpose I/Os" ]
# [ repr ( C ) ]
pub struct GpioRB {
# [ doc = "0x00 - GPIO port mode register" ]
pub moder:RW32,
# [ doc = "0x04 - GPIO port output type register" ]
... | true |
c02670d4bdff03728e75fdea4ae836d5cea14138 | Rust | ergorusty/macroscope | /crates/macroscope/src/derive_parse/validate.rs | UTF-8 | 1,060 | 2.578125 | 3 | [] | no_license | use crate::tools::syn::{
parse::{discouraged::Speculative, Parse, ParseStream},
token::Token,
};
pub trait Validate {
fn validate(stream: &ParseStream) -> bool;
}
impl<T> Validate for T
where
T: Token,
{
fn validate(stream: &ParseStream) -> bool {
T::peek(stream.cursor())
}
}
pub trai... | true |
8d615f8d436f4c2e38665a9fc4d2fbd02e6d2ecc | Rust | jamesmarva/The-Rust-Programming-Language | /code/ch15/code_15_23/src/lib.rs | UTF-8 | 780 | 3.25 | 3 | [] | no_license | use std::cell::RefCell;
trait Messenger {
fn send(&self, messsage: &str);
}
struct MockMessenger {
sent_messages_vec: RefCell<Vec<String>>,
}
impl MockMessenger {
fn new() -> MockMessenger {
MockMessenger{
// sent_messages_vec: RefCell::new(Vec::new()),
sent_messages_ve... | true |
b5db02c143f1e53501fa34b55bb38f631fd32760 | Rust | matthewmichihara/advent-of-code | /2021/01/1.rs | UTF-8 | 484 | 2.890625 | 3 | [] | no_license | use std::io;
fn main() -> io::Result<()> {
let reader = include_str!("input.txt");
let mut last_depth = -1;
let mut increases = 0;
for line in reader.lines() {
let depth = line.parse::<i32>().unwrap();
if last_depth == -1 {
last_depth = depth;
continue;
... | true |
59260f6c6a2a6b2d012091132baba184e707c043 | Rust | andrewyli/rust-madlibs | /src/main.rs | UTF-8 | 556 | 2.703125 | 3 | [
"MIT"
] | permissive | // Example story: He was so [adjective] that he [verb]ed John in the face,
// sending him into a/an [noun].
extern crate "rust-madlibs" as madlibs;
use madlibs::read_input;
use madlibs::fill_blanks;
fn main() {
// functions in lib.rs
let template = read_input();
let mut story = fill_blanks(template.as_sli... | true |
a2aeee74c1067a6ac88735d597d11cc2d9e73a34 | Rust | jaimeliew1/adventofcode2020rust | /src/bin/day01.rs | UTF-8 | 1,071 | 3.078125 | 3 | [] | no_license | use std::fs;
fn part1(inp_vec: &Vec<i32>) -> i32 {
for (i, a) in inp_vec.iter().enumerate() {
for b in &inp_vec[i + 1..] {
if a + b == 2020 {
return a * b;
}
}
}
unreachable!()
}
fn part2(inp_vec: &Vec<i32>) -> i32 {
for (i, a) in inp_vec.iter().... | true |
3cf745cd5ab83050768100476b0198d3e1ddc517 | Rust | WRansohoff/svd2rust_example_stm32l0x1 | /svd_lib/stm32l0x1/src/exti/imr.rs | UTF-8 | 44,770 | 2.890625 | 3 | [
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::IMR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W... | true |
1dee2165a4ef60df189f8b405236cfc9ba413f94 | Rust | killix/prisma-engines | /migration-engine/core/src/core_error.rs | UTF-8 | 2,133 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use migration_connector::{ConnectorError, ListMigrationsError};
use std::{error::Error as StdError, fmt::Display};
use user_facing_errors::{common::SchemaParserError, KnownError, UserFacingError};
/// The result type for migration engine commands
pub type CoreResult<T> = Result<T, CoreError>;
/// The top-level error ... | true |
fe300544ea467d763963c5950e4285cbfe70649a | Rust | xavierhamel/rack | /src/token/sys.rs | UTF-8 | 1,587 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::compiler::{asm::*, internals, err};
#[derive(Debug, PartialEq, Clone)]
pub enum Token {
Sys(String),
Include,
}
impl Token {
pub fn compile(&self, consts:&HashMap<String, isize>, internals:&mut internals::Internals) -> Result<Vec<Inst>, err::Err> {
match s... | true |
9e4a6f1012a090bd34219589bae17e178b92a850 | Rust | ritobanrc/aoc2015 | /src/day24.rs | UTF-8 | 4,891 | 2.875 | 3 | [] | no_license | use crate::load_input;
use anyhow::Result;
use itertools::Itertools;
crate::aoc!(24);
pub fn day24_main() -> Result<()> {
let input = load_input(24)?
.lines()
.map(str::parse::<u32>)
.collect::<Result<Vec<_>, _>>()?;
assert_eq!(11266889531, part1_solution(&input));
assert_eq!(7738... | true |
21f8d97f955a436a1e60901e6b8287e371d12792 | Rust | boxdot/advent-of-code-2019 | /stiar/day19/src/intcode.rs | UTF-8 | 9,268 | 3.40625 | 3 | [] | no_license | use std::convert::From;
#[derive(Debug, Clone)]
struct Memory {
data: Vec<i64>,
rel_base: i64,
}
impl Memory {
pub fn getm(&self, index: usize, mode: Mode) -> i64 {
let value = self.get(index);
match mode {
Mode::Position => self.get(value as usize),
Mode::Immediate... | true |
71bb7de3c831189be937bc6f339bd67788c77c83 | Rust | kliang622/guessing_game | /src/main.rs | UTF-8 | 1,190 | 3.765625 | 4 | [] | no_license | use std::io; //standard input output
use std::cmp::Ordering;
use rand::Rng; //gets random number in certain range
fn main() {
println!("Hello, guess the number!");
//values are inclusive on lower bound and exclusive on upper bound
let guessNumber = rand::thread_rng().gen_range(1..101);
loop{
... | true |
ba7424e93d6c4bd96cbcb42de661bcd86ea5db1e | Rust | jlgerber/gpi | /src/main.rs | UTF-8 | 3,667 | 3.078125 | 3 | [] | no_license | use gpi::{ GPI, table_record, VcsType };
use structopt::StructOpt;
/// Commands to interact with the Global Package Index, which
/// provides a means to look up the url of a package within
/// one of our heterogeneous version control systems, reducing
/// friction associated with relocating packages within a vcs or
//... | true |
ab30ba7aed174b2011b894216e85177c81a6504a | Rust | booleancoercion/advent-of-code-2020 | /src/day16.rs | UTF-8 | 5,541 | 3.09375 | 3 | [] | no_license | use aoc_runner_derive::*;
struct Rule {
a1: u16,
b1: u16,
a2: u16,
b2: u16,
}
impl Rule {
fn new(ranges: &str) -> Rule {
let mut split_or = ranges.split(" or ");
let first_range = split_or.next().unwrap().trim();
let second_range = split_or.next().unwrap().trim();
... | true |
600a5f4252cf5f0d3d4054a43128b70ddb1fc613 | Rust | koivunej/derive-into-owned | /tests/variant_enum.rs | UTF-8 | 630 | 3.046875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate derive_into_owned;
use std::borrow::Cow;
#[derive(IntoOwned)]
enum Foo<'a> {
Str { a: Cow<'a, str>, b: u32 },
Bytes { a: bool, b: Cow<'a, [u8]> },
}
#[test]
fn enum_with_only_cow_variants() {
let s = "foobar".to_string();
let v = b"12345234".to_vec();
let thing = Foo::S... | true |
71d8f4ef5cd7f846f7b51ec9e40404ffafdc16ea | Rust | Techno-coder/calculator | /src/tests/evaluation.rs | UTF-8 | 1,233 | 3.078125 | 3 | [
"MIT"
] | permissive | use crate::context::Context;
use crate::error::Error;
#[test]
fn test_arithmetic() {
assert_eq!(evaluate("1 + 2"), Ok(3.0));
assert_eq!(evaluate("1 - 2"), Ok(-1.0));
assert_eq!(evaluate("1 * 2"), Ok(2.0));
assert_eq!(evaluate("1 / 2"), Ok(0.5));
assert_eq!(evaluate("10 ^ -2"), Ok(0.01));
}
#[test]
fn test_unary_... | true |
1114b3048ce405b086969fb8f0ea9d4fa4f68ae1 | Rust | doytsujin/googapis | /googapis/genproto/google.cloud.oslogin.common.rs | UTF-8 | 2,775 | 3.0625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// The POSIX account information associated with a Google account.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PosixAccount {
/// Only one POSIX account can be marked as primary.
#[prost(bool, tag = "1")]
pub primary: bool,
/// The username of the POSIX account.
#[prost(string, tag = "... | true |
9aa5b0614c4985c8e6797551288d6bd96d972053 | Rust | sru-systems/rust-kpdb | /src/io/log_writer.rs | UTF-8 | 2,502 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown"
] | permissive | // Copyright (c) 2016-2017 Martijn Rijkeboer <mrr@sru-systems.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, o... | true |
a52a3cda8364656fe34351823a444bf82e2ae628 | Rust | micahsmith/aoc19 | /src/seven.rs | UTF-8 | 2,952 | 3.03125 | 3 | [] | no_license | use crate::intcode::{IntCodeProgram, IntCodeStatus};
pub fn start(input: &str) {
let mut permutations: Vec<Vec<u32>> = Vec::new();
heaps_algo(5, &mut [0, 1, 2, 3, 4], &mut permutations);
run_without_feedback(input, permutations);
let mut permutations: Vec<Vec<u32>> = Vec::new();
heaps_algo(5, &mut... | true |
20236481641c6012e31ba1c23cca13db38144397 | Rust | quek/ar | /src/drv.rs | UTF-8 | 1,735 | 2.765625 | 3 | [] | no_license | use syntax::ast;
use syntax::ast::{MetaItem, Item};
use syntax::codemap::Span;
use syntax::ext::base::{ExtCtxt, Annotatable};
use syntax::ptr::P;
use aster;
use err::Error;
pub fn ar(cx: &mut ExtCtxt,
span: Span,
meta_item: &MetaItem,
annotatable: &Annotatable,
push: &mut FnMut... | true |
9a769e4a690f14d0d83799574a2e26a7bb36a06a | Rust | xd009642/tarpaulin | /tests/data/fork-test/src/lib.rs | UTF-8 | 748 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #[test]
pub fn test1() {
fn child<F: FnOnce()>(f: F) {
match unsafe { libc::fork() } {
0 => f(),
-1 => unreachable!(),
pid => unsafe {
libc::waitpid(pid, core::ptr::null_mut(), 0);
},
}
}
child(|| ());
}
#[test]
pub fn test2() {
... | true |
3835afa5463a42f7cb25a44759c536274199c927 | Rust | hsmtkk/animated-couscous | /src/mst_evl.rs | UTF-8 | 3,141 | 3.09375 | 3 | [] | no_license | struct Monster {
attack: i32,
defence: i32,
speed: i32,
}
impl Monster {
fn new(attack: i32, defence: i32, speed: i32) -> Monster {
Monster {
attack,
defence,
speed,
}
}
}
struct EvoMonster {
name: String,
min_attack: i32,
max_attack:... | true |
f2a289a14ade303e37c3ea36a94eb0b1199bfcb0 | Rust | Pfarrer/rust-jvm | /_deprecated/src/vm/eval/baload.rs | UTF-8 | 656 | 2.609375 | 3 | [] | no_license | use vm::Vm;
pub fn eval(vm: &mut Vm, pc: u16) -> Option<u16> {
let (value, index) = {
let frame = vm.frame_stack.last_mut().unwrap();
let index = frame.stack_pop_int() as usize;
let rc_array = frame.stack_pop_arrayref();
let mut array = rc_array.borrow_mut();
// Array must ... | true |
c000a83e7773ed1016cd1c5a006ffce512ba0d4c | Rust | htunlogic/rust-todo-app | /src/services/jwt.rs | UTF-8 | 1,898 | 3.234375 | 3 | [] | no_license | use chrono::prelude::*;
use jsonwebtoken;
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Claims {
pub sub: String,
pub email: String,
pub exp: i64,
pub iat: i64,
}
/// Generate JWT for passed User
pub fn generate(user: &crate::models::user::User) -> String {
let secret = match dotenv::var... | true |
c1b349aa7aad9fe429226d8393f4df44bc4a0e73 | Rust | PistonDevelopers/meta | /examples/hello_world.rs | UTF-8 | 672 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate piston_meta;
use piston_meta::*;
fn main() {
let text = r#"hi James!"#;
let rules = r#"
1 say_hi = ["hi" .w? {"James":"james" "Peter":"peter"} "!"]
2 document = say_hi
"#;
// Parse rules with meta language and convert to rules for parsing text.
let rules = match syntax... | true |
daaabbadc0463dfbaf337e2fdbf403bfb69134b6 | Rust | virtous/RustyBrain | /src/main.rs | UTF-8 | 461 | 2.671875 | 3 | [
"MIT"
] | permissive | pub mod brain;
use brain::tokenizer::tokenizer;
use brain::read::read;
fn main() {
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
println!("Welcome to RustyBrain 0.1.0");
println!("RustyBrain is a simple BrainF*ck interpreter written in Rust");
println!("Type 'ctrl+c' to exit");
loop {
le... | true |
e2c02e76a9991f291d92ac62e5d4bd507cc93f8f | Rust | jimenezrick/katas | /rust/loop.rs | UTF-8 | 492 | 3.5 | 4 | [] | no_license | struct Foo {
x: i32,
}
impl Drop for Foo {
fn drop(&mut self) {
println!("drop Foo{{{}}}", self.x)
}
}
fn main() {
let v = vec![1, 2, 3];
for e in &v {
println!("{}", e);
println!("{}", v.len());
}
println!(
"\\x -> x+1: {:?}",
v.iter().map(|x| x +... | true |
8e2f5d20753fde86ae0606907f348ba37fd82690 | Rust | platonist0/club_coding | /src/custom_csrf.rs | UTF-8 | 4,511 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use csrf::{AesGcmCsrfProtection, CsrfProtection};
use data_encoding::BASE64;
use rocket::fairing::AdHoc;
use rocket::http::Cookie;
use rocket::request::{self, FromRequest, Request};
use rocket::{Outcome, State};
use time::Duration;
/// Struct for CSRF secret key.
/// Used in endpoints that requires the
/// CSRF secret... | true |
229fa7d8b82566ff1dd342669ca11c2ee5970eb4 | Rust | chaaz/adventofcode_2018 | /day_07/src/part1.rs | UTF-8 | 2,180 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
pub fn run() {
let content = include_str!("input.txt").trim().split("\n");
let mut graph = Graph::new();
for req in content.map(Req::from_line) { graph.add_req(req); }
let mut available = graph.init();
while !available.is_empty() {
available.sort();
let next = availab... | true |
8a0dce8e2923524aa15153623a3793545e8fff4d | Rust | u-03c9/sctp | /src/param/param_header.rs | UTF-8 | 1,578 | 2.796875 | 3 | [
"MIT"
] | permissive | use super::{param_type::*, *};
use bytes::{Buf, BufMut, Bytes, BytesMut};
use std::fmt;
#[derive(Default, Debug, Clone, PartialEq)]
pub(crate) struct ParamHeader {
pub(crate) typ: ParamType,
pub(crate) value_length: u16,
}
pub(crate) const PARAM_HEADER_LENGTH: usize = 4;
/// String makes paramHeader printab... | true |
6da677108e85c7bfbb6a096cfb4406b8c5c91978 | Rust | HeroicKatora/oxide-auth | /oxide-auth/src/endpoint/mod.rs | UTF-8 | 26,539 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Polymorphic HTTP wrappers for code grant authorization and other flows.
//!
//! An endpoint is concerned with executing the abstract behaviours given by the backend in terms
//! of the actions of the endpoint types. This means translating Redirect errors to the correct
//! Redirect http response for example or opti... | true |
78eefd5370f06deb1c5bb37e39bf1f359784af55 | Rust | HayaoSuzuki/tlpi | /chap06/modify_env/src/main.rs | UTF-8 | 694 | 2.921875 | 3 | [] | no_license | use std::env;
fn modify_env(args: &Vec<String>) {
for (key, _) in env::vars() {
env::remove_var(key);
}
for arg in args {
let splited_arg: Vec<_> = arg.split('=').collect();
let (key, value) = (&splited_arg[0], &splited_arg[1]);
env::set_var(key, value);
}
if env::... | true |
108e8705a298c41cb8703b41ec255b7c1c09336f | Rust | szabgab/slides | /rust/examples/hashes/get_value_from_hash.rs | UTF-8 | 303 | 3.15625 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let counter = HashMap::from([
("foo", 1),
("bar", 2),
]);
println!("{}", counter["foo"]);
println!("{:?}", counter.get("foo"));
// println!("{}", counter["zz"]); // panic
println!("{:?}", counter.get("zz")); // None
}
| true |
6ec46133746be4f5ca553db1b51027d13a84a6e3 | Rust | marhel/komp | /komp-cli/src/pattern.rs | UTF-8 | 8,680 | 2.90625 | 3 | [] | no_license | use crate::play::{Event, TimedEvent};
pub fn create_note(
timing: u32,
length: u32,
channel: u8,
note: u8,
velocity: u8,
) -> (TimedEvent, TimedEvent) {
(
TimedEvent {
timing: timing,
event: Event::NoteOn {
channel,
note,
... | true |
0b8683eb461d27bc1743e9719515382e6a83e7c0 | Rust | mendes5/engine-rs | /math/src/mat4.rs | UTF-8 | 9,178 | 3.03125 | 3 | [] | no_license | // REF:: https://github.com/mrdoob/three.js/blob/dev/src/math/Matrix4.js
use super::{Quat, Vec3};
#[derive(Debug)]
pub struct Mat4 {
pub elements: [f32; 16],
}
impl Mat4 {
pub fn new() -> Self {
Self {
#[rustfmt::skip]
elements: [
1.0, 0.0, 0.0, 0.0,
... | true |
dac0ad9b6879994491a297d2c0f6615362617e8c | Rust | zmilan/stork | /src/index_versions/v2/structs.rs | UTF-8 | 2,650 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use super::scores::*;
use crate::Fields;
use crate::IndexFromFile;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::convert::TryInto;
pub type EntryIndex = usize;
pub type AliasTarget = String;
pub type Score = u8;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub(super) struct Entry {
... | true |
b8d06e1392da656f2f08d9f045162e13e0a97edd | Rust | sokach-dev/defer-lite | /src/lib.rs | UTF-8 | 1,976 | 3.546875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A Rust implementation of
//! [Go's `defer` statement](https://tour.golang.org/flowcontrol/12) as the
//! `defer!` macro, which executes a block of code when the surrounding scope
//! ends.
//!
//! This crate focuses on providing a lightweight, high-performance, `no_std`
//! implementation of the `defer!` macr... | true |
79077cb4d0affe2781a390b1dfd3c6cb842facfe | Rust | LaylBongers/clink | /src/visualstudio/filters.rs | UTF-8 | 5,207 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::{Path, PathBuf};
use std::fs::File;
use std::io::Write;
use uuid::Uuid;
use xml::writer::{XmlEvent, EmitterConfig};
use visualstudio::{ProjFiles};
use wincanonicalize::wincanonicalize;
struct FileEntry {
location: PathBuf,
class: String,
filter: String,
}
fn add_filter_recursive(filters: &m... | true |
c76f34a1d10bf6805fea083974337718aff1ce17 | Rust | strassl/jssp-heuristics | /src/solver/random_restart_hill_climber.rs | UTF-8 | 2,314 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::data::{Instance, Solution};
use crate::solver::{
generate_random_solution, get_orientation_from_schedule, n1, IntermediateSolution,
};
use log::{debug, info, trace};
use rand::SeedableRng;
use rand_chacha;
use std::time::{Duration, Instant};
pub struct Config {
pub timeout: Duration,
pub seed: u64,
}
... | true |
7905c4764f4e3270a348e9ddc80aecb6602660b5 | Rust | d3zd3z/euler | /rust/src/pr001.rs | UTF-8 | 442 | 3.296875 | 3 | [] | no_license | // Problem 1
//
// 05 October 2001
//
// If we list all the natural numbers below 10 that are multiples of 3 or 5,
// we get 3, 5, 6 and 9. The sum of these multiples is 23.
//
// Find the sum of all the multiples of 3 or 5 below 1000.
define_problem!(pr001, 1, 233168);
fn pr001() -> u32 {
let mut total = 0;
... | true |
db2157358cd924d1987ee77d80ed34c337186dde | Rust | codyd51/axle | /rust_programs/ttf_renderer/src/character_map.rs | UTF-8 | 14,759 | 2.640625 | 3 | [
"MIT"
] | permissive | use crate::parse_utils::{BigEndianValue, FromFontBufInPlace, TransmuteFontBufInPlace};
use crate::parser::FontParser;
use crate::println;
use alloc::collections::BTreeMap;
use alloc::vec;
use alloc::vec::Vec;
use core::mem;
use core::ops::Range;
use itertools::Itertools;
/// §'cmap' Platforms
#[derive(Debug, Copy, Clo... | true |
50797287c9cb9304ff8219fe6e8fe1ae64b7c00c | Rust | rust-lang/rust | /tests/ui/span/lint-unused-unsafe.rs | UTF-8 | 34,625 | 2.78125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // Exercise the unused_unsafe attribute in some positive and negative cases
// edition:2018
// revisions: mir
// FIXME: Adapt -Zthir-unsafeck to behave the same as the mir version after #93678,
// then delete lint-unused-unsafe-thir.rs, and go back to using the settings below
// // revisions: mir thir
// // [thir]c... | true |
42001e963042798711ccddb9e977a04742744849 | Rust | gallegogt/mailchimp-rs | /src/types/list_member_goals.rs | UTF-8 | 2,781 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use super::link::LinkType;
use crate::api::MailchimpApi;
use crate::iter::{BuildIter, MailchimpCollection, SimpleFilter};
use serde::{Deserialize, Serialize};
use std::rc::Rc;
///
/// List Member Goal
///
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ListMemberGoal {
/// The id for a Goal event.
#[... | true |
ad58bf7552ad5839008948ba08e0fabc90e22a53 | Rust | reeceyang/cryptography | /src/elliptic_elgamal.rs | UTF-8 | 693 | 2.984375 | 3 | [] | no_license | use rug::Integer;
use crate::elliptic_curves::*;
// prime p, elliptic curve E over Fp, point P in E(Fp)
#[derive(Debug)]
pub struct EllipticElgamal {
pub E: EllipticCurve,
pub P: Point
}
impl EllipticElgamal {
pub fn generate_public_key(&self, nA: &Integer) -> Point {
multiply(&self.P, nA, &self.E... | true |
e121729589a92113e71a2eb9eb374abc8bdd8406 | Rust | Mr-Wrecker/Dungeon-Game | /src/main.rs | UTF-8 | 3,940 | 3.25 | 3 | [
"MIT"
] | permissive | use crossterm::{
terminal::{Clear, ClearType},
QueueableCommand,
};
use rand::{prelude::SliceRandom, thread_rng};
use std::{
io::{stdin, stdout},
thread,
time::Duration,
};
const ROW_NUMBER: i32 = 5;
const COL_NUMBER: i32 = 5;
fn main() {
clear();
show_help();
thread::sleep(Duration::f... | true |
ddef72e0d780421ccd9e08e15d049e8deaea45ad | Rust | alex-norton/advent-of-code-2020 | /src/bin/day16-2.rs | UTF-8 | 2,900 | 2.96875 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fs::read_to_string;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let field_re = Regex::new(r"([\w ]*):")?;
let range_re = Regex::new(r"([0-9]+)-([0-9]+)")?;
let input = read_to_string("data/day16input")?;
... | true |
2d849c98e18fd7d50424f2cf8b47165680e179d8 | Rust | herzbergs/mult430 | /src/main.rs | UTF-8 | 4,329 | 2.546875 | 3 | [
"MIT"
] | permissive | #![no_main]
#![no_std]
#![feature(abi_msp430_interrupt)]
extern crate panic_msp430;
use once_cell::unsync::OnceCell;
use msp430::interrupt as mspint;
use msp430_rt::entry;
use msp430g2231::{interrupt};
use msp430_atomic::{AtomicU16, AtomicBool};
mod pulses;
use pulses::{SyncSignal, SyncKind};
mod timer_state;
use t... | true |
b44c901df7a801d5af5fc54f3b995b26a88687ff | Rust | Winwardo/poker-kata | /src/poker/card_rank.rs | UTF-8 | 834 | 3.546875 | 4 | [] | no_license | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub enum CardRank {
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Jack = 11,
Queen = 12,
King = 13,
Ace = 14,
}
impl CardRank {
pub fn to_string(&self) -> &... | true |
2875606934719e4b7908cc5f9fbc7c86dff883cb | Rust | magiclen/chinese-number | /src/number_to_chinese/number_to_chinese_error.rs | UTF-8 | 644 | 3.453125 | 3 | [
"MIT"
] | permissive | use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use std::error::Error;
/// 將數值轉成中文數字時發生的錯誤。
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum NumberToChineseError {
Overflow,
Underflow,
}
impl Display for NumberToChineseError {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> R... | true |
05357d6779000f3f9edbe4c2e520c51c7858ecaa | Rust | Pandinosaurus/point_cloud_viewer | /sdl_viewer/src/graphic/tiled_texture_loader.rs | UTF-8 | 4,214 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use byteorder::{LittleEndian, ReadBytesExt};
use image::{GenericImage, GenericImageView, ImageBuffer, LumaA, Pixel, Rgba};
use num_integer::Integer;
use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
/// Little trait that just dispatches to the correct read_xyz_into call for... | true |
35947f45e7dbe0ca2e770c22ee1ba05c4543ab38 | Rust | yama-sitter/rust-trial | /src/ownership.rs | UTF-8 | 2,476 | 3.6875 | 4 | [] | no_license | pub fn run() {
let s1 = String::from("hello");
let s2 = s1;
println!("{}", s2);
let i1 = 1;
let i2 = i1;
println!("{} {}", i1, i2);
println!("Stack address of i1 is: {:p}", &i1);
println!("Stack address of i2 is: {:p}", &i2);
let sl1 = "literal";
let sl2 = sl1;
println!("{} {}", sl1, sl2);
pri... | true |
40c705c74cdf7a0886e380c281226714ec2a493e | Rust | joshmarlow/ai_kit-rs | /src/constraints/tests.rs | UTF-8 | 10,811 | 2.796875 | 3 | [
"MIT"
] | permissive | use constraints::*;
#[cfg(test)]
mod solver_tests {
use super::*;
#[test]
fn test_solve_multi_constraint() {
let constraints = from_json!(Vec<Constraint>, [
{
"numerical": {
"set": {
"variable": "?diff",
"constant": 5.0,
},
... | true |
d8a235d0827b23806ffbfbc96ed8fdea5d8289b2 | Rust | 3v0k4/aoc20 | /day02/src/main.rs | UTF-8 | 1,619 | 3.546875 | 4 | [] | no_license | use std::convert::TryInto;
#[derive(Debug, Clone)]
struct Line {
first: i32,
second: i32,
c: char,
password: String
}
fn main() {
let lines1: Vec<Line> = parsed_input()
.iter()
.filter(is_valid_1)
.cloned()
.collect();
let lines2: Vec<Line> = parsed_input()
.iter()
.filter(is_vali... | true |
5f5ca8cfbcec7825524f4169a36115ba6a95815d | Rust | richardwhiuk/adventofcode | /2020/rust/src/bin/nineteen.rs | UTF-8 | 3,845 | 3.3125 | 3 | [] | no_license | pub use rust::*;
fn main() -> Result<()> {
a("input/nineteen-test.txt")?;
a("input/nineteen.txt")?;
b("input/nineteen-test.txt")?;
b("input/nineteen.txt")?;
Ok(())
}
#[derive(Default)]
struct Puzzle {
rules: HashMap<usize, Rule>,
messages: Vec<String>,
}
enum RulePart {
SubRule(usiz... | true |
f2fece4cf56b23e678f07f417120b55b40132e08 | Rust | alilee/arm-rust-clust | /src/pager/bump.rs | UTF-8 | 2,151 | 3.171875 | 3 | [
"Unlicense"
] | permissive | // SPDX-License-Identifier: Unlicense
//! Allocate pages within a range, without dealloc.
//!
//! Suited for device MMIO range.
use super::{Addr, AddrRange, VirtAddr, VirtAddrRange, PAGESIZE_BYTES};
use crate::Result;
use core::fmt::{Debug, Formatter};
/// An allocator of pages within a single range.
pub struct Pag... | true |
7ad4a61d17f11391c54cc806d26d73463d4da62d | Rust | craniumrat/AoC2020 | /day6/src/main.rs | UTF-8 | 1,561 | 3.609375 | 4 | [
"MIT"
] | permissive | use std::io::{self, BufRead};
use std::fs::File;
use std::collections::HashSet;
use itertools::Itertools;
fn main() -> Result<(), std::io::Error> {
let file = File::open("input.txt")?;
let reader = io::BufReader::new(file);
let mut entries : Vec<String> = Vec::new();
let mut entry = String::new()... | true |
3642dd3a7072e0d41472a93c77e728c66b9a6a32 | Rust | facebookexperimental/MIRAI | /checker/tests/run-pass/switch.rs | UTF-8 | 958 | 2.8125 | 3 | [
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//
use mirai_annotations::*;
pub enum Foo {
Zero,
One,
Two,
Three,
Four,
Five,
}
pub fn foo(foo: Foo) -> u32 {
... | true |
ab1f025cd0f04f5c329ff670becb00a8746c6c8e | Rust | NickRoz1/noodles | /noodles-tabix/src/index/reference_sequence/builder.rs | UTF-8 | 2,715 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use noodles_bgzf as bgzf;
use super::{
bin::{self, Chunk},
Bin, ReferenceSequence,
};
const WINDOW_SIZE: u32 = 16384;
#[derive(Debug, Default)]
pub struct Builder {
bin_builders: HashMap<u32, bin::Builder>,
intervals: Vec<bgzf::VirtualPosition>,
}
impl Builder {
p... | true |
f8ade7a24e9d620f8800ab15281037ccf04de353 | Rust | barzilouik/flowbetween | /curves/src/bezier/path/point.rs | UTF-8 | 2,897 | 3.46875 | 3 | [
"Apache-2.0"
] | permissive | use super::path::*;
use super::to_curves::*;
use super::super::curve::*;
use super::super::normal::*;
use super::super::intersection::*;
use super::super::super::coordinate::*;
///
/// Returns true if a particular point is within a bezier path
///
pub fn path_contains_point<P: BezierPath>(path: &P, point: &P::Point) ... | true |
3c2f184ad11b47fe0baf79a3914dc60327de1176 | Rust | stevelr/zenkit-rs | /src/types.rs | UTF-8 | 61,043 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![allow(missing_docs, clippy::upper_case_acronyms)]
//! This module defines the data types used in the ZenKit Api. Most are specified
//! by [Zenkit API Docs](https://base.zenkit.com/docs/api/overview/introduction),
//! and a few have been added to make the code more Rust-idiomatic.
//!
//! Structs defined here that a... | true |
0bc3cf523ccd60dfc6fa57261fadea5e0cc17116 | Rust | kvakvs/ErlangRT | /lib-erlangrt/src/big.rs | UTF-8 | 1,774 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
defs,
emulator::heap::THeap,
fail::RtResult,
term::{
boxed::{self, endianness::Endianness},
Term,
},
};
use core::ptr;
/// Helper, creates a new big integer on heap with val.
pub fn from_isize(hp: &mut dyn THeap, val: isize) -> RtResult<Term> {
let p = boxed::Bignum::with_isize(hp, val... | true |
dd1b569a809cff20c8fec0067ceb49d2d96078ed | Rust | sigod/codewars | /src/moves-in-squared-strings-i.rs | UTF-8 | 1,208 | 3.171875 | 3 | [
"MIT"
] | permissive | fn hor_mirror(s: String) -> String {
let mut result = String::with_capacity(s.len());
for row in s.split('\n').rev() {
result.push_str(row);
result.push('\n');
}
if !result.is_empty() {
let new_length = result.len() - 1;
result.truncate(new_length);
}
result
}
fn vert_mirror(s: String) -> String {
le... | true |
04673ac13aed113c5719703ce8a8ce3536f98c9a | Rust | Pfarrer/rust-jvm | /_deprecated/src/vm/eval/caload.rs | UTF-8 | 682 | 2.703125 | 3 | [] | no_license | use vm::Vm;
use vm::primitive::Primitive;
pub fn eval(vm: &mut Vm, pc: u16) -> Option<u16> {
let frame = vm.frame_stack.last_mut().unwrap();
let index = frame.stack_pop_int() as usize;
let rc_array = frame.stack_pop_arrayref();
let array = rc_array.borrow();
assert_eq!(array.atype.unwrap(), 5);
... | true |
f3cfd56a5b0c1a213024c4d565149eb98a054c14 | Rust | krait-yxin/tornado | /common/logger/src/lib.rs | UTF-8 | 15,838 | 2.609375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::elastic_apm::{get_current_service_name, ApmTracingConfig};
use arc_swap::ArcSwap;
use crate::filter::FilteredLayer;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use thiserror::Error;
use tracing::subscriber::set_global_default;... | true |
1551a2ccb5058c2026c3bc9aa8e0beba2aa26157 | Rust | teuvo486/ble2json-rs | /src/device/mod.rs | UTF-8 | 1,300 | 2.75 | 3 | [
"MIT"
] | permissive | mod ruuvi3;
mod ruuvi5;
use super::dbus::{Conn, MfgData};
use super::Result;
use ruuvi3::Ruuvi3;
use ruuvi5::Ruuvi5;
use serde::Serialize;
use std::io::Cursor;
#[derive(Clone, Debug, Serialize)]
#[serde(untagged)]
enum SensorData {
Ruuvi3(Ruuvi3),
Ruuvi5(Ruuvi5),
}
impl SensorData {
fn new(dict: MfgData)... | true |
ce7676de1d7e9ba753c447ed9149ce0601bffab8 | Rust | epage/pushgen | /src/lib.rs | UTF-8 | 6,114 | 3.75 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! Push-style design pattern for processing of ranges and data-streams.
//!
//! This is a Rust-based approach to the design pattern described by [transrangers](https://github.com/joaquintides/transrangers).
//! While the discussion linked targets C++, the same basic principle of pull-based iterators applies
//! to Rus... | true |
6061b162df807e2c7d19e1002eca760548f9f0ad | Rust | marceloboeira/trpl | /chapters/chapter-13/example07.rs | UTF-8 | 144 | 2.984375 | 3 | [
"MIT"
] | permissive | fn main() {
let v1 : Vec<i32> = vec![1, 2, 3];
let v2 : Vec<_> = v1.iter().map(|x| x + 1).collect();
println!("Sum: {:?}", v2);
}
| true |
0cbdf96f5a2847d85a070718d05594cb35873195 | Rust | xjump/MeiliDB | /meilidb-core/src/lib.rs | UTF-8 | 9,426 | 2.703125 | 3 | [
"MIT"
] | permissive | mod automaton;
mod distinct_map;
mod query_builder;
mod store;
pub mod criterion;
use std::fmt;
use std::sync::Arc;
use rayon::slice::ParallelSliceMut;
use serde::{Serialize, Deserialize};
use slice_group_by::GroupBy;
use zerocopy::{AsBytes, FromBytes};
pub use self::query_builder::{QueryBuilder, DistinctQueryBuilde... | true |
b81012e99487198d76cb4f068ac391afbd0bf153 | Rust | dsherret/swc | /ecmascript/transforms/compat/src/bugfixes/edge_default_param.rs | UTF-8 | 3,040 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use swc_ecma_ast::*;
use swc_ecma_visit::{noop_fold_type, Fold, FoldWith};
/// Converts destructured parameters with default values to non-shorthand
/// syntax. This fixes the only arguments-related bug in ES Modules-supporting
/// browsers (Edge 16 & 17). Use this plugin instead of
/// @babel/plugin-transform-paramet... | true |
8a46f1bcf5c76bf94a69d46a2232d9e71cd8d3e4 | Rust | Gonlos/roman-numerals-kata | /rust/src/main.rs | UTF-8 | 1,919 | 3.859375 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
}
fn to_roman_numeral(x: i16) -> String {
return "I".to_string();
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn to_roman_numeral_1() {
let expected = "I";
let result = to_roman_numeral(1);
assert_eq!(expected, result);
}
... | true |
8e10f3687f0b6c0304db5647173cd245bb7c2a96 | Rust | yjhmelody/leetcode-rust | /src/majority_element.rs | UTF-8 | 603 | 3.65625 | 4 | [
"MIT"
] | permissive | #![allow(dead_code)]
pub fn majority_element(nums: Vec<i32>) -> i32 {
let mut count = 0;
let mut temp = nums[0];
for num in nums {
if num == temp {
count += 1;
} else if count == 0 {
temp = num;
count += 1;
} else {
count -= 1;
... | true |
429277be4b17d9a1a9ac577f6bdfa23723dfff97 | Rust | AlbanMinassian/env-lang | /src/lib.rs | UTF-8 | 1,548 | 3.015625 | 3 | [
"MIT"
] | permissive | //! # env-lang
//!
//! [](https://travis-ci.org/AlbanMinassian/env-lang)
//! [](https://codecov.io/gh/AlbanMinassian/env-lang)
//! [![License:MIT](https:... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.