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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8fcbbac1ad4fe8536797fe888f793fa6b28c9eef | Rust | arkena00/rs.ndb | /experimental/main.rs | UTF-8 | 1,777 | 2.921875 | 3 | [] | no_license | #![feature(custom_attribute)]
use ndb;
use std::string::ToString;
struct Field<T>
{
f_01: T
}
#[concept(storable)]
struct Movie
{
test: Field<i32>,
id:i32,
name:String,
}
impl Movie
{
fn save(&self)
{
println!("save {}", self.name);
}
}
#[derive(Default)]
struct Query
{
da... | true |
fa8abae02529c1175d1b78d6a4c5d7f86440e0cf | Rust | darrenldl/blockyarchive | /src/integer_utils.rs | UTF-8 | 1,659 | 3 | 3 | [
"MIT"
] | permissive | pub trait IntegerUtils {
type Item;
fn round_down_to_multiple(_: Self::Item, _: Self::Item) -> Self::Item;
fn round_up_to_multiple(_: Self::Item, _: Self::Item) -> Self::Item;
fn ensure_at_least(_: Self::Item, _: Self::Item) -> Self::Item;
fn ensure_at_most(_: Self::Item, _: Self::Item) -> Self::Ite... | true |
73ca586e7f3ec9b1e67519b0c2f6e106508dfbc3 | Rust | lqhuang/advent-of-code-2020 | /src/bin/day04.rs | UTF-8 | 15,837 | 3.578125 | 4 | [] | no_license | //! # --- Day 4: Passport Processing ---
//!
//! You arrive at the airport only to realize that you grabbed your North Pole
//! Credentials instead of your passport. While these documents are extremely
//! similar, North Pole Credentials aren't issued by a country and therefore
//! aren't actually valid documentation f... | true |
94c1d0c0d10cdd07d9a79df6c23ed3cc0a105cfb | Rust | rust-lang/rust-analyzer | /crates/cfg/src/cfg_expr.rs | UTF-8 | 5,071 | 3.203125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! The condition expression used in `#[cfg(..)]` attributes.
//!
//! See: <https://doc.rust-lang.org/reference/conditional-compilation.html#conditional-compilation>
use std::{fmt, slice::Iter as SliceIter};
use tt::SmolStr;
/// A simple configuration value passed in from the outside.
#[derive(Debug, Clone, PartialE... | true |
a0dceb17c2342650843d8de87229e26e86c8386d | Rust | cljacoby/leetcode | /src/valid-anagram/valid-anagram.rs | UTF-8 | 796 | 3.71875 | 4 | [
"MIT"
] | permissive | // https://leetcode.com/problems/valid-anagram
use std::collections::HashMap;
struct Solution;
impl Solution {
pub fn char_counts(s: String) -> HashMap<char, usize> {
let mut map = HashMap::with_capacity(s.len());
for ch in s.chars() {
*map.entry(ch).or_insert(0) += 1;
}
... | true |
5fe7c7c7c0b49f70f6382e6d86ddf8669eb1a676 | Rust | aresbit/evian-blog | /backend/src/database/article/admin.rs | UTF-8 | 3,514 | 2.65625 | 3 | [] | no_license | use super::Database;
use super::models::*;
use super::super::neo4j_ops;
use neo4j_ops::Neo4jStatement;
use std::error;
use std::fmt;
type Result<T> = std::result::Result<T, Error>;
impl Database {
pub async fn post_article(&self, article: Article) -> Result<()> {
match article {
Article { se... | true |
15eab1a3922d6ac0d63ea95be8c503ad1c94d0a7 | Rust | little-dude/error-handling-presentation | /src/no_error_handling.rs | UTF-8 | 1,451 | 3.4375 | 3 | [] | no_license | use std::{fs::File, io::Read};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub enum Operator {
#[serde(rename = "+")]
Add,
#[serde(rename = "-")]
Sub,
#[serde(rename = "*")]
Mul,
#[serde(rename = "/")]
Div,
}
#[derive(Serialize, Deserialize, Debug)]
p... | true |
be15a98cca43dcd9409fe1494a05847d54e7986d | Rust | azaharakis/toy-robot-rust | /src/movement.rs | UTF-8 | 989 | 3.390625 | 3 | [] | no_license | use crate::direction::Direction;
use crate::point;
pub fn get_direction_to_left(direction: &Direction) -> Direction {
match direction {
Direction::North => Direction::East,
Direction::East => Direction::South,
Direction::South => Direction::West,
Direction::West => Direction::North,... | true |
46b671525cdf14025411277b9632629a42afc3f3 | Rust | D4niel44/shared_secrets | /src/math/modular.rs | UTF-8 | 22,049 | 3.6875 | 4 | [
"MIT"
] | permissive | use std::fmt::Display;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use rug::{
integer::Order,
ops::{RemRounding, RemRoundingAssign},
Integer,
};
use crate::math::{error::ParseIntegerError, random::Rng, Field, Prime};
/// This structure represents a modular integer numb... | true |
b023f8365e4238e8d3a183bdf275500d29b699f2 | Rust | polachok/bioyino | /src/parser.rs | UTF-8 | 5,481 | 2.796875 | 3 | [
"Unlicense"
] | permissive | use combine::byte::{byte, bytes, newline};
use combine::combinator::{eof, skip_many};
use combine::range::{take_while, take_while1};
use combine::{optional, Parser};
use metric::{Metric, MetricType};
use std::fmt::Debug;
use std::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign};
use std::str::FromStr;
use std::str::from... | true |
5217b473548ae9fe76fe8eb2b2c9b9e0b98bcc13 | Rust | JosephLenton/fortress | /hlr/src/theme/theme.rs | UTF-8 | 3,149 | 3.328125 | 3 | [] | no_license | use game::GameTile;
use llr::LLRPixel;
use theme::colours;
use world::tiles::Tile;
/// This holds the colour type.
pub struct Theme {}
impl Theme {
/// Trivial constructor.
pub fn new() -> Theme {
Theme {}
}
/// Gets the players draw information.
pub fn get_player(&self) -> LLRPixel {
... | true |
8cf01eeaaf58a4e406490fa9f1648c8fc9000fc3 | Rust | pickjob/rust-starter | /examples/frame/async/async-std.rs | UTF-8 | 383 | 2.53125 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use async_std::fs;
use async_std::prelude::*;
use std::error::Error;
#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
let path = "C:\\code";
let mut dir = fs::read_dir(&path).await?;
while let Some(res) = dir.next().await {
let entry = res?;
println!("... | true |
f6c688b1d562c72fe1b9d1886646ab73d32896bb | Rust | FoamCactus/euler | /src/problems/problem7.rs | UTF-8 | 564 | 3.6875 | 4 | [] | no_license | pub fn problem7() {
println!("The 10,001th prime is {}", get_nth_prime(10001));
}
fn get_nth_prime(n: usize) -> i32 {
if n == 1 {
return 2;
}
let mut i = 1;
let mut primes : Vec<i32> = vec![2];
primes.push(2);
while primes.len() <= n {
i = i + 2;
let mut is_prime: bo... | true |
2f43923ed3f8cee3d1cc18a5f1c6278096ab7aee | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/tessoku-book/src/bin/c10.rs | UTF-8 | 391 | 3.015625 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
w: usize,
};
// 12 * 7^(w-1)
let p = 1_000_000_007_usize;
let mut b = 7_usize;
let mut x = w - 1;
let mut y = 12;
for _ in 0..60 {
if (x & 1) == 1 {
y *= b;
y %= p;
}
b *= b;
b %= ... | true |
2f312473cdc8b1ce38af1c58fef66e728b69365a | Rust | bch29/battlebots | /support/src/config.rs | UTF-8 | 2,147 | 3.109375 | 3 | [
"MIT"
] | permissive | use math::*;
use std::time::Duration;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct Config {
/// The size of the world.
pub world_size: Vector2,
/// The frame rate of the simulation (but not necessarily the rendering).
pub ticks_per_second: u32,
/// The number of ticks be... | true |
c47d5ab3a5749bef7182fcf34498c95e138a24d2 | Rust | Keruspe/adventofcode2020 | /src/bin/05.rs | UTF-8 | 774 | 3.15625 | 3 | [] | no_license | use std::io::{BufRead, Cursor};
use std::collections::HashSet;
static INPUT: &str = include_str!("./05.txt");
fn parse_bin(s: &str, one: char) -> u64 {
s.chars().fold(0, |acc, c| acc * 2 + if c == one { 1 } else { 0 })
}
fn parse_seat(s: &str) -> (u64, u64) {
let (col, row) = s.split_at(7);
(parse_bin(co... | true |
06a11c7e2e0a2e00e371407dcde275c2f1ad200f | Rust | dropbox/pb-jelly | /examples/src/linked_list/main.rs | UTF-8 | 631 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use pb_jelly::Message;
use proto_linked_list::node::Node;
fn main() -> std::io::Result<()> {
// Creat our head node
let mut head = Node {
content: "Hello".to_owned(),
next: None,
};
// Create a second node
let next_node = Node {
content: "World".to_owned(),
next: Non... | true |
e1d2a34bec431d165816c81a568822902f32dc7b | Rust | PsypherPunk/advent-of-code | /2020/15/benches/day15.rs | UTF-8 | 1,019 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs;
use criterion::{criterion_group, criterion_main, Criterion};
use ::day15::*;
pub fn benchmark_get_nth_number_for_input_2020(c: &mut Criterion) {
let input = fs::read_to_string("input.txt").expect("Error reading input.txt");
let numbers = get_numbers(&input);
c.bench_function("get_nth_number... | true |
1110c8928e34dc6e2b1287078ca49cf8e5a5344d | Rust | rednum/interval_trees | /examples/ps_max.rs | UTF-8 | 4,527 | 3.53125 | 4 | [
"BSD-2-Clause"
] | permissive | extern crate interval_tree;
use interval_tree::pointsegment::{PointSegmentTree};
use std::cmp::{max};
fn main() {
// In this example, I will show how to use the point-segment
// tree to implement a data structure for storing points and
// answering queries about them. Each point belongs in
// predet... | true |
28abbd034e8d20f4f42aa621ecd5f6c50e9560e9 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/warp/src/test.rs | UTF-8 | 20,125 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | /
/
!
Test
utilities
to
test
your
filters
.
/
/
!
/
/
!
[
Filter
]
(
.
.
/
trait
.
Filter
.
html
)
s
can
be
easily
tested
without
starting
up
an
HTTP
/
/
!
server
by
making
use
of
the
[
RequestBuilder
]
(
.
/
struct
.
RequestBuilder
.
html
)
in
this
/
/
!
module
.
/
/
!
/
/
!
#
Testing
Filters
/
/
!
/
/
!
It
'
s
easy
t... | true |
86931c2a968a38b5106de8116030fed1cf7fa955 | Rust | killercup/rune | /crates/runestick/src/bytes.rs | UTF-8 | 4,148 | 3.546875 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! A container of bytes, corresponding to the [Value::Bytes] type.
//!
//! [Value::Bytes]: crate::Value::Bytes.
use crate::{FromValue, Mut, RawMut, RawRef, Ref, UnsafeFromValue, Value, VmError};
use std::fmt;
use std::ops;
/// A vector of bytes.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Byte... | true |
6d9af65d4557eb955e5445ec0398bdbcfea96549 | Rust | macpp/hir_syn_test | /test_4_lint/src/lib.rs | UTF-8 | 232 | 2.96875 | 3 | [] | no_license | pub fn do_something () {
let x = foo();
let y = bar();
println!("x: {} , y: {}", x, y);
}
use std::sync::Arc;
fn foo() -> String {
"asdf".to_owned()
}
fn bar() -> Arc<String> {
Arc::new("super bar".to_owned())
} | true |
f49efb74ae4ab58dff7ea16249f9a21637633dc4 | Rust | YosiSF/EinsteinDB | /berolinasql/src/json_merge.rs | UTF-8 | 9,905 | 2.59375 | 3 | [
"MIT"
] | permissive | //Copyright 2021-2023 WHTCORPS INC
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file File except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to ... | true |
429eaf15f1d42f04ced79da91e114b74c7b3d92f | Rust | ardave/BME280 | /src/register.rs | UTF-8 | 1,004 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt::Display;
use std::fmt::Result;
use std::fmt::Formatter;
/// Enum mapping sensor hex addresses to human-readable values.
#[derive(Debug)]
pub enum Register {
T1 = 0x88,
T2 = 0x8A,
T3 = 0x8C,
P1 = 0x8E,
P2 = 0x90,
P3 = 0x92,
P4 = 0x94,
P5 = 0x96,
P6 = 0x98,
P7 = 0x9... | true |
e89229831c49e4e7f8aa8f5137a93e38c857fc14 | Rust | carlmartus/rscsg | /src/dim2/csg.rs | UTF-8 | 2,731 | 2.984375 | 3 | [] | no_license | use dim2::{BspNode, Line, Point};
use {Unit, UNIT_PI};
#[derive(Clone)]
pub struct Csg {
pub lines: Vec<Line>,
}
impl Csg {
pub fn new() -> Csg {
Csg { lines: Vec::new() }
}
pub fn from_lines(lines: Vec<Line>) -> Csg {
Csg { lines }
}
pub fn to_lines(&self) -> Vec<Line> {
... | true |
d68bf8a0544abd8c34bc309468a8e2f56adaa0ae | Rust | brettkolodny/incantation-catastrophe | /src/systems/animation_systems/rook_run.rs | UTF-8 | 1,200 | 2.53125 | 3 | [] | no_license | use crate::components::{CurrentFrame, Rook};
use crate::resources::CurrentState;
use amethyst::core::Time;
use amethyst::ecs::{Join, Read, ReadStorage, System, WriteStorage};
use amethyst::renderer::SpriteRender;
pub struct RookRunSystem;
impl<'s> System<'s> for RookRunSystem {
type SystemData = (
ReadSto... | true |
725cf955805338e9744ff778b6dbf404879b1e78 | Rust | Prometeo/rust_tutorial | /projects/structs/basic_struct_instances/src/main.rs | UTF-8 | 586 | 3.3125 | 3 | [] | no_license | struct User {
username: String,
email: String,
sing_in_count: u64,
active: bool,
}
let user1 = User {
email: String::from("someone@example.com"),
username: String::from("someusername123"),
active:true,
sing_in_count: 1,
};
let user2 = User {
email: String::from("another@example.com... | true |
9438b63c26d02d2f0143b4780d07005a5209610d | Rust | LuoZijun/es | /crates/eschar/src/lib.rs | UTF-8 | 3,080 | 3.171875 | 3 | [
"MIT"
] | permissive | mod id;
mod white_space;
use crate::id::{ ZWJ, ZWNJ, DOLLAR_SIGN, LOW_LINE, };
use crate::white_space::{
TAB, VT, FF, SP, NBSP, ZWNBSP,
CR, LF, LS, PS,
};
pub use crate::id::{ is_id_start, is_id_continue, is_id_continue_only, };
pub use crate::white_space::{ is_es_line_terminator, is_es_whitespace, };
// Sin... | true |
31479f0d6f6e4a5450ba57d7d909f7c8351116e2 | Rust | andersengqvist/adventofcode-2020 | /src/day12.rs | UTF-8 | 6,359 | 3.28125 | 3 | [] | no_license | use crate::day;
use crate::file;
use lazy_static::lazy_static;
use regex::Regex;
pub struct Day12 {
}
impl day::Day for Day12 {
fn puzzle1(&self) {
println!("Day 12, puzzle 1");
let result = get_result_1(&file::lines("res/day12_1.txt"));
println!("{}", result);
}
fn puzzle2(&... | true |
4a26b4493ed0223015722633438a9ddccc2e5bee | Rust | sogapalag/contest | /codeforces/634/3f.rs | UTF-8 | 3,970 | 2.828125 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Read, BufWriter, Write};
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}
fn get_word() -> String {
let stdin = s... | true |
dd3b73c95178c56bb8d4e8e365aaf06acdc11c6a | Rust | xiankai/advent-of-code | /2020/03 - toboggan trajectory/src/main.rs | UTF-8 | 1,332 | 3.5625 | 4 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead, Error};
fn read_input(path: &str) -> Result<Vec<String>, Error> {
let file = File::open(path)?;
let br = BufReader::new(file);
let mut v = vec![];
for line in br.lines() {
v.push(line?)
}
Ok(v)
}
fn traverse_slope(terrain: &[String],... | true |
441ae66b681166d9c5476fe270006117484f227f | Rust | panzerox123/rkeep | /src/utils/club.rs | UTF-8 | 2,836 | 3.359375 | 3 | [] | no_license | use rusqlite::{params, Connection, Result};
use std::fs;
#[derive(Debug)]
pub struct Club {
pub id: u32,
pub club_name: String,
pub club_path: String,
}
pub fn open_connection() -> Connection {
let connection = Connection::open("./testdb");
let connection = match connection {
Ok(c) => c,
... | true |
57a6f0c906e014cc84a923ffe6bb285926ba54ac | Rust | aunetx/text-translator | /src/api/mod.rs | UTF-8 | 2,432 | 3.234375 | 3 | [
"MIT"
] | permissive | use crate::*;
use async_trait::async_trait;
pub mod yandex;
pub use yandex::Yandex;
pub mod google_v2;
pub use google_v2::GoogleV2;
/// A trait defining a translate API.
///
/// Implements `new()` to return a new API, and `translate()` to translate a text.
#[async_trait]
pub trait Api {
/// Returns a new API str... | true |
bf9d78c0787235941ef495cb70e9c728bf408654 | Rust | autophagy/nu_plugin_from_dhall | /src/from_dhall.rs | UTF-8 | 2,722 | 2.90625 | 3 | [
"MIT"
] | permissive | use indexmap::indexmap;
use nu_errors::ShellError;
use nu_protocol::{ReturnSuccess, ReturnValue, TaggedDictBuilder, UntaggedValue, Value};
use nu_source::Tag;
use serde_dhall::{NumKind, SimpleValue};
pub struct FromDhall {
pub state: String,
pub name_tag: Tag,
}
impl FromDhall {
pub fn new() -> Self {
... | true |
790458138f4361fe224df70436b4832b7f9e6b00 | Rust | DelSkayn/rquickjs | /core/src/loader/script_loader.rs | UTF-8 | 1,161 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::{
loader::{util::check_extensions, Loader},
module::ModuleData,
Ctx, Error, Result,
};
/// The script module loader
///
/// This loader can be used as the nested backing loader in user-defined loaders.
#[derive(Debug)]
pub struct ScriptLoader {
extensions: Vec<String>,
}
impl ScriptLoader {... | true |
7248dfc8ab9dd69780ae87a71131bd23dd4af06a | Rust | lauras5/rust_server | /src/http/query_string.rs | UTF-8 | 875 | 3.53125 | 4 | [] | no_license | use std::collections::HashMap;
pub struct QueryString<'buf> {
data: HashMap<&'buf str, Value<'buf>>,
}
pub enum Value <'buf>{
// 2 variants
Single(&'buf str),
Multiple(Vec<&'buf str>) // specify len of arr at compile, need to heap allocate to grow dynamically
}
impl <'buf> QueryString<'buf> {
pub... | true |
4afa63b1329c3a0c952cbbad5f51eb78188f1eb4 | Rust | curtiseng/leetcode_rust | /src/stack/main.rs | UTF-8 | 968 | 3.921875 | 4 | [
"Apache-2.0"
] | permissive | struct Stack {
items: Vec<String>,
count: i32,
n: i32
}
fn main() {
let mut stack = Stack::new(2);
stack.push(String::from("hello"));
stack.push(String::from("world"));
println!("count: {}", stack.count);
println!("item: {}", stack.pop());
println!("item: {}", stack.pop());
prin... | true |
c0bdeb3eccaf5ea24da050750170f0d5072866f5 | Rust | mvromer/AdventOfCode | /2018/Day04/day4b/src/main.rs | UTF-8 | 1,309 | 2.734375 | 3 | [] | no_license | use aoc_shared::day4::{self, GuardEvent, SleepCounts};
use chrono::naive::NaiveDateTime;
use std::collections::BTreeMap;
fn main() {
let cli = aoc_shared::parse_command_line( "Advent of Code Day 4b" );
let guard_events = day4::read_guard_events( &cli ).expect( "Failed to read guard events" );
let sleepiest... | true |
1b03a340a6d39c45c074bf719081b65a50fb56c9 | Rust | xofyarg/rust-kres | /src/lib.rs | UTF-8 | 15,150 | 2.71875 | 3 | [
"MIT"
] | permissive | //! This crate wraps [libkres](https://knot-resolver.cz) from
//! [CZ.NIC Labs](https://labs.nic.cz). libkres is an implementation of a full DNS recursive resolver,
//! including cache and DNSSEC validation. It doesn't require a specific I/O model and instead provides
//! a generic interface for pushing/pulling DNS mes... | true |
2b73a4edaf3c0b0adb75bbbb0de48b7715c58d19 | Rust | sile/nasbench-rs | /src/lib.rs | UTF-8 | 2,939 | 2.734375 | 3 | [
"MIT"
] | permissive | //! A Rust port of [google-research/nasbench][NASBench].
//!
//! [NASBench]: https://github.com/google-research/nasbench
//!
//! # Motivations
//!
//! Of course, the primary purpose of this crate is to make [NASBench] dataset available in Rust.
//! Besides, another aim is to reduce dataset loading time.
//! By using a ... | true |
1018d1557ad261f2a8ea3e20bb74fa657512f681 | Rust | hhatto/metl | /examples/metal_triangle.rs | UTF-8 | 1,143 | 2.640625 | 3 | [] | no_license | extern crate metl;
use metl::extras::window::{Event, WindowBuilder, View, ViewDelegate};
use metl::{ClearColor, PixelFormat};
fn main() {
struct MyViewDelegate;
impl ViewDelegate for MyViewDelegate {
fn draw_into_view(&self, view: &mut View) {
view.draw();
}
fn on_resize(&s... | true |
5f7e54d5425530d18e932e8e3480306f214c0477 | Rust | jasilven/sandbox-rs | /src/bin/rclj.rs | UTF-8 | 10,899 | 2.6875 | 3 | [] | no_license | use anyhow::{anyhow, bail, format_err, Result};
use edn::parser::Parser;
use rustyline::error::ReadlineError;
use rustyline::Editor;
use std::boxed::Box;
use std::collections::{BTreeMap, HashMap};
use std::io::BufReader;
use std::io::{stderr, stdout, BufRead};
use std::io::{Read, Write};
use std::net::TcpStream;
use st... | true |
86e8d37ea78a86369e5a331055203cfd9f257a19 | Rust | Trivaxy/leibniz-lang | /runtime/src/optimizations.rs | UTF-8 | 5,302 | 3.234375 | 3 | [] | no_license | use crate::{function::Function, instruction::Instruction, value::Value};
use num_complex::Complex64;
use Instruction::*;
use OptimizationType::*;
enum OptimizationType {
AddInPlace(f64, f64),
SubtractInPlace(f64, f64),
MultiplyInPlace(f64, f64),
DivideInPlace(f64, f64),
RaiseInPlace(f64, f64),
... | true |
eec3d060038d047eb723b14e25560574af1b9b08 | Rust | iCodeIN/differential-geometry | /src/coordinates.rs | UTF-8 | 4,540 | 3.484375 | 3 | [
"MIT"
] | permissive | //! Module containing basic types representing coordinate systems.
use super::tensors::{ContravariantIndex, CovariantIndex, Matrix, Tensor};
use crate::typenum::consts::U2;
use crate::typenum::uint::Unsigned;
use crate::typenum::Pow;
use generic_array::{ArrayLength, GenericArray};
use std::fmt;
use std::ops::{Index, I... | true |
6906446c5bece5cd5fcb7a31fa2345888fe3b051 | Rust | Gammaglobulino/http_server_in_rust | /src/http/response.rs | UTF-8 | 1,056 | 3.03125 | 3 | [] | no_license |
use std::net::TcpStream;
use std::io::{Write,Result as IoResult};
use std::fmt::{Display,Formatter,Result as FmtResult};
use super::StatusCode;
#[derive(Debug)]
pub struct Response{
status_code:StatusCode,
body:Option<String>,
}
impl Response{
pub fn new(status_code:StatusCode,body:Option<String>) -> Se... | true |
e21003b30f515f9a050d4ac964b9905e282b99dc | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-29092.rs | UTF-8 | 424 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
// Regression test for Issue #29092.
//
// (Possibly redundant with regression test run-pass/issue-30530.rs)
use self::Term::*;
#[derive(Clone)]
pub enum Term {
Dummy,
A(Box<Term>),
B(Box<Term>),
}
// a small-step evaluator
pub fn small_eval(v: Term) -> Term {
match v {
A(t) => *t... | true |
430a6158d9d88d70167835725893494d29ecb33e | Rust | Ainevsia/Leetcode-Rust | /576. Out of Boundary Paths/src/lib.rs | UTF-8 | 1,216 | 3.25 | 3 | [
"BSD-2-Clause"
] | permissive | pub struct Solution {}
impl Solution {
pub fn find_paths(m: i32, n: i32, max_move: i32, start_row: i32, start_column: i32) -> i32 {
if max_move == 0 { return 0 }
let m = m as usize;
let n = n as usize;
let max_move = max_move as usize;
let mut dp = vec![vec![vec![0usize; n];... | true |
4d04a85f05c21a9b61ff15a73f16f77a9b25988e | Rust | andjo403/Interner | /src/meta_data.rs | UTF-8 | 14,946 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::atomic_wait::{wait, wake_all};
use std::sync::atomic::{fence, AtomicU64, Ordering};
/// This bit is set instead of h2 if valid bit is not set when that mutex is locked by some thread.
const LOCKED_BIT: u8 = 0x80;
const PARK_BIT: u8 = 0x40;
const GROUP_FULL_BIT_MASK: u64 = 0x7f00_0000_0000_0000;
const GROUP_... | true |
100f5ebce060a16a3555f432328bfc23f3169937 | Rust | bgourlie/rs-nes | /rs-nes/src/ppu/status_register/mod.rs | UTF-8 | 2,420 | 2.875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
#[cfg(test)]
mod spec_tests;
use std::cell::Cell;
const VBLANK: u8 = 0b_1000_0000;
const SPRITE_ZERO: u8 = 0b_0100_0000;
const SPRITE_OVERFLOW: u8 = 0b_0010_0000;
#[derive(Default)]
pub struct StatusRegister {
reg: Cell<u8>,
}
impl StatusRegister {
#[cfg(test)]
pub fn new(reg: u8) ... | true |
32935837545e6e4d6fa26b0e2bb05217ab89d30f | Rust | devilbuddy/koboldo | /src/generator/mod.rs | UTF-8 | 8,151 | 3.515625 | 4 | [] | no_license | extern crate rand;
use world::grid::Grid;
use rand::thread_rng;
use rand::{Rng, Rand};
use rand::distributions::Range;
use rand::distributions::IndependentSample;
#[derive(PartialEq, Eq, Hash)]
enum Direction {
Up,
Down,
Left,
Right
}
impl Rand for Direction {
fn rand<R: Rng>(rng: &mut R) -> Di... | true |
1fa9aa56d49e321ee00d6c3cd2221549d4612abd | Rust | dav-s/picrust | /src/orientation.rs | UTF-8 | 269 | 3.09375 | 3 | [] | no_license | #[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub enum Orientation {
Row,
Column,
}
impl Orientation {
pub fn invert(&self) -> Orientation {
match self {
Self::Row => Self::Column,
Self::Column => Self::Row,
}
}
}
| true |
8f38e374eb2deca7a46c25206d588229f5f60662 | Rust | abhijeetbhagat/boa | /boa/src/builtins/value/val_type.rs | UTF-8 | 1,787 | 3.5 | 4 | [
"Unlicense",
"MIT"
] | permissive | use crate::builtins::value::ValueData;
use std::ops::Deref;
/// Possible types of val as defined at https://tc39.es/ecma262/#sec-typeof-operator.
/// Note that an object which implements call is referred to here as 'Function'.
#[derive(Eq, PartialEq, Debug, Clone, Copy)]
pub enum Type {
Undefined,
Null,
Bo... | true |
1ed08ba4a4945f3e1e8afe1f653efa5ea0745076 | Rust | LeedsCodeDojo/TryALanguage-Rust | /solutions/grant/shared.rs | UTF-8 | 370 | 3.3125 | 3 | [] | no_license | use std::thread;
use std::time::Duration;
fn main() {
let mut val = 0;
for _ in 1..10 {
thread::spawn(move || {
val = val + 1;
print!("Value now: {}\n", val);
});
thread::sleep(Duration::from_millis(10));
}
thread::sleep(Duration::from_milli... | true |
d626b6939fb1518f416cf4bcbec36feae8b1e42a | Rust | jakeheis/aquila_rust | /src/parsing/ast.rs | UTF-8 | 11,462 | 2.625 | 3 | [] | no_license | use super::Expr;
use crate::lexing::Token;
use crate::library::*;
use crate::source::*;
use std::cell::RefCell;
#[derive(Debug)]
pub struct TypeDecl {
pub name: SymbolicToken,
pub generics: Vec<Token>,
pub fields: Vec<StructuralVariableDecl>,
pub methods: Vec<FunctionDecl>,
pub meta_methods: Vec<Fu... | true |
736bd1bcb8c7a75cc613822699b132307c8f0899 | Rust | Logarithmus/matrix-ops-rs | /src/matrix.rs | UTF-8 | 9,867 | 3.1875 | 3 | [] | no_license | use std::borrow::Borrow;
use core::ops::{Add, Sub, AddAssign, SubAssign, Index, IndexMut, Mul};
use rand::distributions::{uniform::SampleUniform, Distribution, Standard};
use rand::Rng;
use std::default::Default;
use std::fmt::{self, Debug, Display, Formatter};
use std::iter::{self, Sum};
pub struct Matrix<T> {
da... | true |
c85cbbd9c60ed8811bb806b8ecd804ae88f961c0 | Rust | museun/twitchchat | /src/messages/ping.rs | UTF-8 | 1,299 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | use crate::{irc::*, MaybeOwned, MaybeOwnedIndex, Validator};
/// A ping request from the server
#[derive(Clone, PartialEq)]
pub struct Ping<'a> {
raw: MaybeOwned<'a>,
token: MaybeOwnedIndex,
}
impl<'a> Ping<'a> {
raw!();
str_field!(
/// Token associated with the PING event
token
);... | true |
24aa12db7c2f9e699e11f377f51dfde704d6a00a | Rust | jpdvi/hop | /src/repl/mod.rs | UTF-8 | 596 | 3.03125 | 3 | [] | no_license | use std::io;
pub fn start() {
let mut input = String::new();
println!("Welcome to hell...");
match io::stdin().read_line(&mut input) {
Ok(n) => {
let mut l : super::lexer::Lexer = super::lexer::Lexer::new(&input);
loop {
let tok : super::token::Token = l.next... | true |
769878826764dc01dd566022abfd624f87097da8 | Rust | Cloudxtreme/rs-sync | /src/index.rs | UTF-8 | 3,499 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
use log::Level;
use super::{adler32_sha1, DefaultHashes};
use utils::{ReadExt, to_hex};
/// Hashes files into a Hashes structure from an iterator... | true |
4801055233891a78b2648664e2fdf6a3c7c0262d | Rust | whitten/cfg | /tests/test_sequence.rs | UTF-8 | 2,524 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate cfg;
mod support;
use cfg::*;
use cfg::sequence::Separator::*;
use cfg::usefulness::Usefulness;
use cfg::rule::container::RuleContainer;
#[test]
fn test_sequence() {
let mut cfg: Cfg = Cfg::new();
let (start, elem, sep) = cfg.sym();
cfg.sequence(start).separator(Trailing(sep)).inclusive(1, ... | true |
2e84c1bd6b8a94d17a8c1cc0b37ebfe2ab301a3a | Rust | silky/synless | /pretty/src/layout/layout.rs | UTF-8 | 10,989 | 3.40625 | 3 | [] | no_license | use std::cmp;
use std::fmt;
use super::boundset::BoundSet;
use crate::geometry::{Col, Pos, Bound, Region};
use crate::style::Style;
use crate::notation::Notation;
use self::Layout::*;
pub trait Lay where Self: Clone {
fn empty() -> Self;
fn literal(s: &str, style: Style) -> Self;
fn concat(&self, other:... | true |
620fd57fd0f666fac6f24f97deb8182c222f066f | Rust | tiago-lqt/openexr-bind | /openexr-rs/src/deep/deep_frame_buffer.rs | UTF-8 | 15,333 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | use openexr_sys as sys;
pub use crate::core::{
error::Error,
frame_buffer::{Frame, Slice, SliceRef},
refptr::{OpaquePtr, Ref, RefMut},
PixelType,
};
pub use imath_traits::{Bound2, Vec2};
use std::marker::PhantomData;
use std::ffi::{CStr, CString};
type Result<T, E = Error> = std::result::Result<T, E>... | true |
702e27bfdb2b466af56d7b2f8f02b7ab5aea6dae | Rust | ultimate-research/prc-rs | /param-xml/src/args.rs | UTF-8 | 838 | 2.75 | 3 | [
"MIT"
] | permissive | use clap::Parser;
#[derive(Parser)]
pub struct Args {
#[clap(subcommand)]
pub mode: Mode,
#[clap(long, short, global(true))]
pub label: Option<String>,
#[clap(
long,
short,
global(true),
requires("label"),
help = "Whether to fail if a label does not have a ... | true |
1e8d8f42ce3a612910b05009b1ce7aa8c3c43ee0 | Rust | MackieLoeffel/rust-slabmalloc | /src/lib.rs | UTF-8 | 22,785 | 2.890625 | 3 | [
"MIT"
] | permissive | //! A slab allocator implementation for small objects
//! (< architecture page size).
//!
//! The organization is as follows (top-down):
//!
//! * A `ZoneAllocator` manages many `SCAllocator` and can
//! satisfy requests for different allocation sizes.
//! * A `SCAllocator` allocates objects of exactly one size.
/... | true |
3bea20bd668fd0b2dfe8661c52bed0f93ced7ecf | Rust | japaric/f3 | /src/examples/_04_roulette.rs | UTF-8 | 1,274 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A LED roulette!
//!
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![no_std]
//! #![no_main]
//!
//! extern crate panic_semihosting;
//!
//! use cortex_m_rt::entry;
//! use f3::{
//! hal::{delay::Delay, prelude::*, stm32f30x},
//! led::Leds,
//! };
//!
//! #[entry]
//! fn main() -> ! {
//!... | true |
9f86314a755850c1ce8bdbc08d162587851067b0 | Rust | lazareviczoran/advent-of-code-2018 | /012-subterranean-sustainability/src/main.rs | UTF-8 | 4,138 | 2.8125 | 3 | [] | no_license | #![feature(map_first_last)]
use regex::Regex;
use std::collections::BTreeMap;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let (pots, patterns) = read_input("input.txt");
println!(
"Day 12: Subterranean Sustainability part1 solution\n{:?}",
find_sum_after_20th_gen(&pots, &patterns)
);
print... | true |
459b253066b4c4ea3d0b1b3a8c711d374fcb81e1 | Rust | nzaharov/election-votes-classifier | /src/main.rs | UTF-8 | 3,978 | 2.921875 | 3 | [] | no_license | #[warn(clippy::all)]
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::HashMap;
use std::io;
#[derive(Debug)]
struct VoteAttributeStat {
republican: u32,
democrat: u32,
total: u32,
}
impl VoteAttributeStat {
fn empty() ->... | true |
3d64cf63656a1ebc476c1036b0dd77b3f5548154 | Rust | svmk/fund-watch-bot | /src/market/common/model/cik.rs | UTF-8 | 854 | 3.34375 | 3 | [] | no_license | use crate::prelude::*;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, ValueObject)]
#[value_object(error_type = "Failure", load_fn = "Cik::from_string")]
pub struct Cik(String);
impl Cik {
pub fn from_string(value: String) -> Result<Cik, Failure> {
const CIK_LENGTH: usize = 10;
if val... | true |
bcbf9af6c25382d3cb867b82f4f4361bbee64e71 | Rust | ok-nick/termscp | /src/fs/explorer/builder.rs | UTF-8 | 4,691 | 3.1875 | 3 | [
"MIT"
] | permissive | //! ## Builder
//!
//! `builder` is the module which provides a builder for FileExplorer
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), t... | true |
25b5ec1f71c8d3f20071b1d42cb38c09d87ef858 | Rust | w1r2p1/rust-trailer | /src/presenters/position.rs | UTF-8 | 4,642 | 3.3125 | 3 | [] | no_license | use models::*;
use presenters::*;
#[derive(Debug, Clone)]
pub struct PositionPresenter {
pub position: Position,
pub current_price: f64,
pub btc_price_in_usd: f64,
}
impl PositionPresenter {
pub fn order_presenters(&self) -> Vec<OrderPresenter> {
self.position.orders.clone().i... | true |
5fd2dc28900482ba3dd54f55d2f71dcf1604cece | Rust | nokijp/random-poster | /src/message.rs | UTF-8 | 4,354 | 3.078125 | 3 | [] | no_license | use serde::{Serialize, Serializer, Deserialize, ser::SerializeStruct};
#[derive(PartialEq, Deserialize, Debug)]
#[serde(untagged)]
pub enum Message {
String(String),
WithEmbeds {
content: Option<String>,
embeds: Vec<serde_json::Value>,
},
}
impl Serialize for Message {
fn serialize<S: ... | true |
4be80660b4304e05aec29a65bd6b97c15ba4962b | Rust | thegedge/fittle | /src/profile/enums/display_measure.rs | UTF-8 | 712 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::fields::FieldContent;
use serde::Serialize;
#[derive(Clone, Copy, Debug, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum DisplayMeasure {
Metric,
Nautical,
Statute,
UnknownValue(u64),
}
impl From<FieldContent> for DisplayMeasure {
fn from(field: FieldContent) -> Self {
... | true |
9fcee555ae9b7e899e42e352c1843454aa7638a0 | Rust | Tangent128/webmetro | /src/fixers.rs | UTF-8 | 4,659 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::pin::Pin;
use std::task::{Context, Poll};
use futures::prelude::*;
use pin_project::pin_project;
use tokio::time::{sleep_until, Duration, Instant, Sleep};
use crate::chunk::Chunk;
pub struct ChunkTimecodeFixer {
current_offset: u64,
last_observed_timecode: u64,
assumed_duration: u64,
}
impl Chu... | true |
cbe9e3db6df6046d936deb6be35ba28dc2bb78dc | Rust | Vodurden/chipper | /src/ui/register_display.rs | UTF-8 | 3,516 | 2.90625 | 3 | [] | no_license | use ggez::{Context, GameResult};
use ggez::graphics::{self, Text, DrawParam, FilterMode};
use crate::chip8::Chip8;
use crate::ui::{Assets, Chip8Display, Point2};
pub struct RegisterDisplay {
/// The horizontal position of this display relative to the main window
x: f32,
/// The vertical position of this ... | true |
9d28fc6c4a22e47b237ece951fc726ba50e4e794 | Rust | arusso98Employers/OrganizationOfProgrammingLanguages | /AvengersRust/src/communicator.rs | UTF-8 | 3,905 | 4.0625 | 4 | [] | no_license | #[derive(Debug)]
#[derive(PartialEq)]
pub enum Command
{
Power(bool,i32), // [Increase/Decrease] power by [number].
Missiles(bool,i32), // [Increase/Decrease] missiles by [number].
Shield(bool), // Turn [On/Off] the shield.
Try, // Try calling pepper.
Invalid // [... | true |
8abbbc89768ba4eed5cf92f01c687977fda9b6fa | Rust | koyashiro/genec | /src/genec.rs | UTF-8 | 1,274 | 2.75 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::editorconfig::Config;
#[allow(dead_code)]
pub type ConfigSet = HashMap<String, Config>;
pub mod config {
use std::fs::File;
use std::path::PathBuf;
use anyhow::{Context, Result};
use dirs::config_dir;
#[allow(dead_code)]
pub const CONFIG_ENV: &str =... | true |
4fcc89218fe90a8c30654583005d11da990be3b8 | Rust | fabianbadoi/rusty-pine | /libs/src/sql/contextual_renderer/explicit_representation/mod.rs | UTF-8 | 23,071 | 2.953125 | 3 | [] | no_license | //! The Query parameter renderers receive does not contain enough
//! information to render a query.
//! This module takes care of stuff like:
//! - determining if we will select 'table.column' or just 'column'
//! - figuring out how to exactly to do joins
use crate::common::{BinaryFilterType, UnaryFilterType};... | true |
b3fa99b82f9ba4b7a2b66744b58c07383dfd60e3 | Rust | doytsujin/wezterm | /src/server/codec.rs | UTF-8 | 16,376 | 2.828125 | 3 | [
"MIT"
] | permissive | //! encode and decode the frames for the mux protocol.
//! The frames include the length of a PDU as well as an identifier
//! that informs us how to decode it. The length, ident and serial
//! number are encoded using a variable length integer encoding.
//! Rather than rely solely on serde to serialize and deserializ... | true |
d6f30f7242cee7fc773afbda792e2e55f9030e92 | Rust | alexander-koch/rgo | /src/lexer/test.rs | UTF-8 | 2,417 | 3.453125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
fn assert_tokens(code: &str, expect: &[(TokenKind, Option<&str>)]) {
let got = tokenize(code);
assert_eq!(got.len(), expect.len());
for (got_t, expect_t) in got.iter().zip(expect) {
let nt = Token {
kind: expect_t.0,
value: expect_t.1.map(|s| s.to_owned()),
... | true |
72ac2829ae4ebb5b6838a8e9889d4517353355c8 | Rust | magiclen/qrcode-generator | /src/qr_code_error.rs | UTF-8 | 1,435 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::{
error::Error,
fmt::{self, Display, Formatter},
io,
};
#[cfg(feature = "image")]
use image::ImageError;
#[allow(clippy::upper_case_acronyms)]
/// Errors when encoding QR code.
#[derive(Debug)]
pub enum QRCodeError {
DataTooLong,
IOError(io::Error),
#[cfg(feature = "image")]
Image... | true |
87dffd23c2c5dd699496c640c09cdb00d2e738ce | Rust | expenses/war-against-machines | /src/weapons.rs | UTF-8 | 3,368 | 3.390625 | 3 | [
"MIT"
] | permissive | // The different weapons in the game
use std::cmp::min;
use std::fmt;
use items::Item;
use resources::{Image, SoundEffect};
// The type of weapon
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
pub enum WeaponType {
Rifle,
MachineGun,
PlasmaRifle,
}
impl WeaponType {
// Get the corr... | true |
98e39d293dbd3d56f0c0ba56c6005c229e906f2f | Rust | disconsented/rust-audiomachine | /src/main.rs | UTF-8 | 5,873 | 2.828125 | 3 | [] | no_license | extern crate discord;
use std::path::Path;
use std::fs;
use std::env;
use std::fmt;
use std::time::Duration;
use std::thread;
use discord::{Discord, State};
use discord::model::Event;
const PREFIX: char = '$';
fn main(){
let discord = Discord::from_bot_token(&env::var("DISCORD_TOKEN").expect("Bad DISCORD_TOKEN")... | true |
189a19a655666d9b3325d3a8a54e8a58b7add718 | Rust | kurotych/braintrainrs | /diagonals/src/main.rs | UTF-8 | 2,888 | 3.25 | 3 | [] | no_license | const BLTR: i32 = -1;
const EMPTY: i32 = 0;
const BRTL: i32 = 1;
const M: usize = 5; // rows
const N: usize = 5; // columns
fn rules_for_bltr_correct(i: usize, j: usize, matrix_square: &[[i32; M]; N]) -> bool {
if i > 0 && matrix_square[i - 1][j] == BRTL {
return false;
}
if j < N - 1 && matrix_sq... | true |
8b58495c3ae237987c88bd4a6dc05b1cb440cd11 | Rust | RipleyTom/advent_of_code_2020 | /src/aoc_13.rs | UTF-8 | 2,306 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::Read;
pub struct LineInfo {
earliest: i64,
bus_ids: Vec<i64>,
}
fn parse_data(input_data: &str) -> Result<LineInfo, std::io::Error> {
let data: Vec<&str> = input_data.lines().collect();
let earliest = data[0].parse().unwrap();
let bus_ids = data[1]
.split(',')
.map(|v| if v ==... | true |
97c2a96bb00fae312e76c9803331eeeba1e82516 | Rust | nicholasfagan/euler | /40/champernowne/src/main.rs | UTF-8 | 134 | 2.59375 | 3 | [] | no_license |
fn main() {
let mut digits : Vec<u8> = vec![0];
let mut n = 0;
while digits.len() <= 1000002 {
n += 1;
}
}
| true |
f29ceaad33656dc1fab922159c09f12c0ff698c5 | Rust | FreeMasen/local_form | /src/main.rs | UTF-8 | 2,511 | 2.671875 | 3 | [] | no_license | extern crate csv;
extern crate opener;
extern crate warp;
use warp::{
Filter,
path,
};
use std::{
thread::spawn,
sync::mpsc::channel,
collections::HashMap,
path::PathBuf,
io::prelude::*,
io::BufReader,
};
fn main() {
let (tx, rx) = channel();
let fork = spawn(move || {
... | true |
c87e16d917060bd9e5e4665f079b99ac12549b53 | Rust | theol0403/rustplotlib | /examples/simple.rs | UTF-8 | 2,043 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate rustplotlib;
#[cfg(feature = "native")]
extern crate cpython;
use rustplotlib::{backend, Backend};
use rustplotlib::{Figure, Subplots, Axes2D, Scatter, Line2D, FillBetween};
use std::f64::consts::PI;
fn make_figure<'a>(x: &'a [f64], y1: &'a [f64], y2: &'a [f64]) -> Figure<'a> {
Figure::default().subplo... | true |
25e2adf29915f00646dd7e631845add6e787e359 | Rust | basstabs/parametrizer | /src/term/constantterm.rs | UTF-8 | 1,079 | 3.953125 | 4 | [] | no_license | use crate::Number;
use super::Term;
/// A Term that returns a constant value no matter what value is passed in
pub struct ConstantTerm<T: Number>
{
c: T
}
impl<T:Number> ConstantTerm<T>
{
///Creates a ConstantTerm obtained by parsing a string slice
///
/// # Examples
///
/// ```
/// use... | true |
db74d4497b4ee2d0e80d47a8431891d68d30ec6d | Rust | vedangj044/drogue-cloud | /websocket-integration/src/auth.rs | UTF-8 | 3,889 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | use drogue_client::Context;
use drogue_cloud_service_api::auth::user::authn::{AuthenticationRequest, Outcome};
use drogue_cloud_service_api::auth::user::authz::{AuthorizationRequest, Permission};
use drogue_cloud_service_api::auth::user::{authz, UserInformation};
use drogue_cloud_service_common::client::UserAuthClient;... | true |
4d5e9eaf42717edb9f788eabe5ee10e55f4edc14 | Rust | czyczk/LeetCode | /rust/lc-1031/src/solution/fast.rs | UTF-8 | 916 | 2.859375 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
pub fn max_sum_two_no_overlap(mut nums: Vec<i32>, first_len: i32, second_len: i32) -> i32 {
let n = nums.len();
let (first_len, second_len) = (first_len as usize, second_len as usize);
for i in 1..n {
nums[i] += nums[i - 1];
}
... | true |
7b13e644cce1733c505434caed69a34cac4eb3cd | Rust | EFanZh/LeetCode | /src/problem_1365_how_many_numbers_are_smaller_than_the_current_number/mod.rs | UTF-8 | 529 | 3.0625 | 3 | [] | no_license | pub mod hash_map;
pub trait Solution {
fn smaller_numbers_than_current(nums: Vec<i32>) -> Vec<i32>;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [
(&[8, 1, 2, 2, 3] as &[_], &[4, 0, 1, 1, 3] as &[_]),
(&[6, 5, 4, 8], &[2, 1, ... | true |
aa3856fcea7ebad88cd05fd1f4c3f8574ada4b86 | Rust | ThomasZumsteg/exercism-rust | /bob/src/lib.rs | UTF-8 | 318 | 2.984375 | 3 | [] | no_license | pub fn reply(phrase: &str) -> &'static str {
let p = phrase.trim();
if p == "" { "Fine. Be that way!" }
else if p.find(char::is_uppercase).is_some() &&
p.find(char::is_lowercase).is_none() {
"Whoa, chill out!" }
else if p.ends_with("?") { "Sure." }
else { "Whatever." }
}
| true |
f89f311a48aab21e7543c886d19e6923089cbe6c | Rust | Lokathor/wide | /src/i32x4_.rs | UTF-8 | 15,990 | 2.671875 | 3 | [
"Zlib"
] | permissive | use super::*;
pick! {
if #[cfg(target_feature="sse2")] {
#[derive(Default, Clone, Copy, PartialEq, Eq)]
#[repr(C, align(16))]
pub struct i32x4 { pub(crate) sse: m128i }
} else if #[cfg(target_feature="simd128")] {
use core::arch::wasm32::*;
#[derive(Clone, Copy)]
#[repr(transparent)]
p... | true |
5f160732aa81802b7bd97ea3ac6b83b641e860cd | Rust | yabirgb/Adventofcode | /2018/src/day4.rs | UTF-8 | 3,172 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[aoc(day4, part1)]
pub fn part1 (input: &str) -> i32 {
let mut data:Vec<&str> = input.lines().collect();
// Sorted vector with the ordered log
data.sort();
// A hasmap to store sleep of a guard
// (id, min) -> freq
let mut sleep: HashMap<(String, u32... | true |
ca174bd200a38ee6a10b2b643ac408e06a034caa | Rust | anbenqishi/rust_learn | /test_foo/src/main.rs | UTF-8 | 164 | 3.203125 | 3 | [] | no_license | struct Foo { a: i32 }
impl Foo {
fn bar(&mut self, val: i32) {
self.a = val + 42;
}
}
fn main() {
let mut foo = Foo { a: 0 };
foo.bar(foo.a);
} | true |
6019d0a0c36d2b9d852423099926a0583a6223a7 | Rust | mesalock-linux/crates-io | /vendor/rocket_http/src/parse/checkers.rs | UTF-8 | 295 | 2.875 | 3 | [
"Apache-2.0",
"Unlicense",
"BSD-3-Clause",
"0BSD",
"MIT"
] | permissive | #[inline(always)]
pub fn is_whitespace(byte: char) -> bool {
byte == ' ' || byte == '\t'
}
#[inline]
pub fn is_valid_token(c: char) -> bool {
match c {
'0'..='9' | 'A'..='Z' | '^'..='~' | '#'..='\''
| '!' | '*' | '+' | '-' | '.' => true,
_ => false
}
}
| true |
79a45692f5ce559b158ee97085dea1f53c97ed1f | Rust | arashout/craftinginterperter | /src/main.rs | UTF-8 | 1,695 | 2.796875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::io;
mod scanner;
use crate::scanner::{Scanner, ScannerError};
mod ast;
mod parser;
mod rpn;
mod token;
mod utils;
fn main() {
if env::args().len() > 2 {
println!("Usage: jlox [script]");
} else if env::args().len() == 2 {
run_script(&env::args().last().expe... | true |
c389fd3466a921d71ab2ac534c7b456a4ca6698c | Rust | Asjidkalam/ruo | /src/algorithms.rs | UTF-8 | 1,064 | 3.03125 | 3 | [
"MIT"
] | permissive | use sha2::{Digest, Sha256, Sha512};
pub fn create_hash(line: &str, hash_length: usize) -> String {
match hash_length {
// MD5
32 => {
let hashvalue = md5::Md5::digest(line.as_bytes());
format!("{:x}", hashvalue)
}
// SHA-1
40 => {
use sha... | true |
64a7a240e7d56891aedc8c42c7f208330f8a096c | Rust | likr-sandbox/rust-js-sandbox | /src/mithril/core.rs | UTF-8 | 956 | 2.71875 | 3 | [] | no_license | extern crate webplatform;
use std::rc::Rc;
use std::cell::RefCell;
use self::webplatform::Event;
pub enum AttributeValue {
Text(String),
EventHandler(Box<FnMut(&mut Event)>),
}
pub type Attribute = (String, AttributeValue);
pub struct Element {
pub tag: String,
pub attributes: Vec<Attribute>,
pu... | true |
ecb8fd354bfaabbdf7ae342f7abbd3825eb77a88 | Rust | JungleComputing/constellation-rust | /examples/vector_add/main.rs | UTF-8 | 5,492 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | //! An example program of how to perform vector addition using Constellation.
//!
//! This program uses a divide and conquer approach for the solution,
//! recursively creating new activities to solve the sub problems.
extern crate constellation_rust;
use std::env;
use std::process::exit;
use std::sync::{Arc, Mutex};... | true |
dcfd6df8c1d4a83c2ae8de2ea98b3c28183a5651 | Rust | teemid/aoc2020 | /src/day9/main.rs | UTF-8 | 2,007 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader};
fn main() -> io::Result<()> {
let f = File::open("src/day9/input_day9.txt")?;
let f = BufReader::new(f);
let preamble_size = 25;
let mut message: Vec<i64> = vec![];
for line in f.lines() {
let line = line.unwrap()... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.