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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b9a3757bc6fb3de5aa8ee157dd28a2960ef9ac05 | Rust | dav000/gemini | /src/resources.rs | UTF-8 | 2,277 | 3.078125 | 3 | [
"MIT"
] | permissive | use serde::de::Deserialize;
use serde_json;
use std::{collections::HashMap, str};
use economy::Commodity;
use entities::Faction;
use entities::PlanetEconomy;
/// Generic Resource trait to be implemented by all resource types which should
/// be loaded at compile time.
/// KEY must be unique to the specific resource (... | true |
73abab06c7d233fd45b92d3b75f9b1ddf229adc7 | Rust | ia7ck/competitive-programming | /AtCoder/abc209/src/bin/a/main.rs | UTF-8 | 285 | 2.515625 | 3 | [] | no_license | use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let a: u32 = rd.get();
let b: u32 = rd.get();
if a <= b {
println!("{}", b - a + 1);
} else {
println!("0");
}
}
| true |
2ec1b5af8e79aa6ba4e3dd6f094aaf40011fc5d8 | Rust | miquels/nntp-rs | /src/util/wildmat_fn.rs | UTF-8 | 8,986 | 2.859375 | 3 | [
"MIT"
] | permissive | //! Wildmat function.
//!
//! This is a straight port of Rich Salz's `wildmat.c` to rust (and it shows).
//!
//! The license asks to include this notice:
//! This product includes software developed by Rich Salz.
// From the original wildmat.c:
//
// Copyright 1991 Rich Salz.
// All rights reserved.
// $Re... | true |
3a731470ae38327686760569fd601a25b9fe11fe | Rust | donaldducky/advent-of-code | /2019/day7/src/main.rs | UTF-8 | 3,021 | 3 | 3 | [] | no_license | use std::cmp;
use std::collections::VecDeque;
use std::thread;
use std::thread::JoinHandle;
use std::sync::mpsc;
use std::sync::mpsc::Sender;
use std::sync::mpsc::Receiver;
use intcode;
use intcode::CPU;
fn main() {
let program = intcode::read_program("input.txt");
println!("Part 1: {}", max_thruster_signal(pr... | true |
10348b3c69cf952dbf4ef779db26572678f5cdd1 | Rust | quail-lang/quail | /src/stg/heap.rs | UTF-8 | 1,308 | 3.015625 | 3 | [
"BSD-2-Clause"
] | permissive | use std::collections::HashMap;
use super::machine::{Closure, Addr};
#[derive(Debug, Clone)]
pub struct Heap {
map: HashMap<Addr, Closure>,
next_addr: Addr,
}
impl Heap {
pub fn new() -> Self {
Heap {
map: HashMap::new(),
next_addr: 0 as Addr,
}
}
// TODO ... | true |
74e30056e6af31f8bbaf69bb9cc3776f734e7611 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/serde_with/src/flatten_maybe.rs | UTF-8 | 2,900 | 3.234375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /
/
/
Support
deserializing
from
flattened
and
non
-
flattened
representation
/
/
/
/
/
/
When
working
with
different
serialization
formats
sometimes
it
is
more
idiomatic
to
flatten
/
/
/
fields
while
other
formats
prefer
nesting
.
Using
#
[
serde
(
flatten
)
]
only
the
flattened
form
/
/
/
is
supported
.
/
/
/
/
/
/
T... | true |
698b65d1b885fb2d8bda25f07dad3308d983cdf4 | Rust | swift-school/google-cloud-rs | /google-cloud/src/pubsub/topic.rs | UTF-8 | 3,488 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use crate::pubsub::api;
use crate::pubsub::{Client, Error, Subscription, SubscriptionConfig};
/// Represents the topic's configuration.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TopicConfig {
pub(crate) labels: HashMap<String, String>,
}
impl TopicConfig {
/// Attach a ... | true |
5e74e043790d7ea7bf102761a92d4d0c3b8c6366 | Rust | joshhartigan/semicircle | /code/rust/try-rust.rs | UTF-8 | 2,175 | 4.09375 | 4 | [
"BSD-2-Clause"
] | permissive | #[allow(unused_variables)]
#[allow(unused_assignments)]
fn main() {
greet_the_world();
// * the following two declarations
// are the same - aside from identifiers.
// * they are both immutable.
// * therefore, they must be initialised
// immediately
let x = 5;
let y:i32 = 5;
... | true |
d2487253d28c3a1fa098b9b6f3573f92fb5ab90d | Rust | blueluna/psila | /psila-data/src/device_profile/active_endpoints.rs | UTF-8 | 6,464 | 2.984375 | 3 | [
"MIT"
] | permissive | use core::convert::TryFrom;
use crate::common::address::NetworkAddress;
use crate::device_profile::Status;
use crate::pack::{Pack, PackFixed};
use crate::Error;
// 2.4.3.1.6 Active_EP_req
/// Active endpoint request
/// Requests the active endpoints for a remote device
#[derive(Clone, Debug, PartialEq)]
pub struct Ac... | true |
e1b0d8915ad573c8aec5e94fc6b1a1b5f00c134f | Rust | tari-project/tari | /base_layer/mmr/src/common.rs | UTF-8 | 14,668 | 2.671875 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... | true |
847da9e8a4981860a1b4cbdd10ae740ca7f60b22 | Rust | hsmtkk/animated-couscous | /src/nice_shopping.rs | UTF-8 | 1,204 | 3.84375 | 4 | [] | no_license | enum Category {
Food, // 0
Book, // 1
Clothing, // 2
Misc, // 3
}
struct Item {
category: Category,
price: u32,
}
impl Item {
fn new(category:Category, price:u32) -> Item {
Item{category, price}
}
}
fn solve(items:Vec<Item>) -> u32 {
let mut point = 0;
... | true |
3c881ce749586162f4337a21ba480088484e8815 | Rust | rust-lang/rust | /tests/ui/borrowck/suggest-local-var-for-vector.rs | UTF-8 | 161 | 2.75 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | fn main() {
let mut vec = vec![0u32; 420];
vec[vec.len() - 1] = 123; //~ ERROR cannot borrow `vec` as immutable because it is also borrowed as mutable
}
| true |
f8d26d39d56d32a68145857844822ed83cfc98c8 | Rust | brprice/advent-of-code | /2019/rust/src/bin/day21.rs | UTF-8 | 1,155 | 3.078125 | 3 | [] | no_license | use aoc2019::intcode::*;
use aoc2019::sparse::*;
/* Today was a "jump over the holes" game - you either move forward one square, or jump over three.
* It seems impossible to ensure success (i.e. not falling into a hole) with finite look-ahead, but
* these strategies work for my inputs */
fn main() {
let mem: Sp... | true |
69cbb2d525a94c49390aeabd0f2b8ca957d405e0 | Rust | cristianoliveira/funzzy | /src/rules.rs | UTF-8 | 9,557 | 2.71875 | 3 | [
"MIT"
] | permissive | extern crate glob;
extern crate yaml_rust;
use crate::cli;
use crate::yaml;
use self::glob::Pattern;
use self::yaml_rust::Yaml;
use self::yaml_rust::YamlLoader;
use crate::stdout;
use std::fs::File;
#[warn(unused_imports)]
use std::io::prelude::*;
#[derive(Debug, Clone)]
pub struct Rules {
pub name: String,
... | true |
ecdb29111c932dcbc7242a96dcfa09acc835c5f7 | Rust | katharostech/PolyFS | /src/cli/config.rs | UTF-8 | 4,547 | 3.171875 | 3 | [] | no_license | //! `config` subcommand. Also contains utilities for accessing commandline
//! config.
use crate::app::config::{AppConfig};
use crate::PolyfsResult;
use crate::cli::{ArgSet, ConfigFormat};
use crate::try_to;
use clap::{value_t, App, ArgMatches, SubCommand};
use std::fs;
use std::io::Write;
use std::path::Path;
pub ... | true |
8c0f981bcfcd59a4cd20c3ac6cedeb9d3548030f | Rust | sisshiki1969/ruruby | /ruruby/src/builtin/range.rs | UTF-8 | 13,538 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::*;
#[derive(Debug, Clone, Hash)]
pub struct RangeInfo {
pub start: Value,
pub end: Value,
pub exclude: bool,
}
impl RangeInfo {
pub(crate) fn new(start: Value, end: Value, exclude: bool) -> Self {
RangeInfo {
start,
end,
exclude,
}
}
... | true |
8f4311a0c1d883b6bb5392a662201a46aba585eb | Rust | nyeogmi/moogle | /src/test_props/floating_poms/mod.rs | UTF-8 | 3,680 | 2.921875 | 3 | [] | no_license | // NOTE: These test modules are written in a way that's intended to make use of rustc
// Specifically, if you see "unused import", you can probably bet that the property listed here
// is not provided (or at least not tested for)
// This lets you spot-check what each bimap has
mod fixture;
mod properties;
use crate::Fl... | true |
7bafccfb74156b06ea45a78e3f27d62d36868bd2 | Rust | cpud36/oid-str | /src/ops.rs | UTF-8 | 4,223 | 2.96875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use core::ops::RangeBounds;
use crate::{index::slice_error_fail, AbsoluteOid, RelativeOid};
impl RelativeOid {
pub fn split_at(&self, mid: usize) -> (&RelativeOid, &RelativeOid) {
if self.is_arc_boundary(mid) {
let (first, last) = self.as_bytes().split_at(mid);
unsafe {
... | true |
1f26ce8d3798ff59dae88d418a3aa4826e939412 | Rust | melkibalbino/rust-conc-e-perf-seguro | /05-Vetores-strings-e-tipos-genericos/string-06-chars-bytes/src/main.rs | UTF-8 | 415 | 3.21875 | 3 | [] | no_license | fn main() {
let name = String::from("rust");
for chr in name.chars() {
println!("Char: {}", chr);
}
println!("--------------------------");
for bt in name.bytes() {
println!("Byte: {}", bt);
}
println!("--------------------------");
// iterar com indice
for (idx,... | true |
7c983271d474a78fe489df0884a012af2b7964b4 | Rust | zmitchell/actix-test | /src/server/mt.rs | UTF-8 | 1,232 | 2.78125 | 3 | [] | no_license | //! mtbl executor actor
extern crate mtbl;
extern crate serde_cbor;
use actix::prelude::*;
use slog;
use std;
use mtbl::Read;
use logger;
/// This is mtbl executor actor. We are going to run 3 of them in parallel.
pub struct MtblExecutor {
pub reader: std::sync::Arc<mtbl::Reader>,
pub logger: slog::Logger,
... | true |
62bbcc2fcc2f27d372ac189d140d78373ba9a43a | Rust | lnicola/serde_fix | /fix50sp2/src/instrmt_leg_sec_list_grp.rs | UTF-8 | 2,193 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct InstrmtLegSecListGrp {
/// Number of legs that make up the Security
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "555")]
pub legs: Option<fix_common::RepeatingValues<Leg>>,
}
... | true |
d845ae49ea4dddd41b9ec857a2b42b7c22db0b66 | Rust | gengteng/esbuild-rs | /src/bin/main.rs | UTF-8 | 1,270 | 2.9375 | 3 | [
"MIT"
] | permissive | use esbuild_rs::ast::{join_all_with_comma, Expr, ExprKind};
use esbuild_rs::logging::MsgCounts;
use std::fmt::Debug;
trait DebugPrintln: Debug {
fn debug_println(&self) {
println!("{:?}", self);
}
}
impl<T: Debug> DebugPrintln for T {}
fn main() {
let msg_count = MsgCounts {
errors: 0,
... | true |
5264a0a26095431e3c57d0f41ab157e183c12a23 | Rust | doytsujin/yew | /packages/yew/src/functional/hooks/use_prepared_state/mod.rs | UTF-8 | 4,821 | 3.03125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[cfg(feature = "hydration")]
pub(super) mod feat_hydration;
#[cfg(all(feature = "hydration", feature = "ssr"))]
mod feat_hydration_ssr;
#[cfg(not(any(feature = "hydration", feature = "ssr")))]
pub(super) mod feat_none;
#[cfg(feature = "ssr")]
mod feat_ssr;
#[cfg(all(feature = "hydration", not(feature = "ssr")))]
pub ... | true |
c081a103f0d170ac199b5218c843fa7b800a87e7 | Rust | harrier-lcc/yubihsm-rs | /src/commands/put_object.rs | UTF-8 | 665 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! The `YubiHSM2` doesnt' have a unified put object command, however all of the put object
//! commands share a common structure, which is what is below.
use {Algorithm, Capability, Domain, ObjectId, ObjectLabel};
/// Common parameters to all put object commands
#[derive(Serialize, Deserialize, Debug)]
pub(crate) st... | true |
4d272a0bf7c6825ee142e7fdcdb55c5d8a2354d4 | Rust | Cherryhz/blog | /src/main.rs | UTF-8 | 1,382 | 2.828125 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
extern crate tera;
use rocket_contrib::templates::Template;
use rocket_contrib::serve::StaticFiles;
use tera::Context;
struct Post {
title: String,
subtitle: String,
}
/*
fn post_list() -> Vec<Post> {
let p1 = Post { title: "... | true |
02b814b6647722b66d1d7bf57c1aa3f05b3c3e65 | Rust | thchittenden/rust-kernel | /src/collections/hashmap.rs | UTF-8 | 6,243 | 3.59375 | 4 | [] | no_license | /// A simple hash map implementation based on separate chaining.
///
/// We chose to use separate chaining as insertions can't fail as they can with something like
/// open-addressing. A consequence of this however is that keys must always be derivable from their
/// values.
///
/// Currently uses lookup_{or_insert}_... | true |
93d364739e757664c519f35ac94bbe998522a2dd | Rust | vi/timeago | /src/languages/japanese.rs | UTF-8 | 825 | 2.890625 | 3 | [
"MIT"
] | permissive | use super::super::{Language, TimeUnit};
#[derive(Default)]
pub struct Japanese;
impl Language for Japanese {
fn clone_boxed(&self) -> super::super::BoxedLanguage { Box::new(Self{}) }
fn too_low(&self) -> &'static str {
"今"
}
fn too_high(&self) -> &'static str {
"後"
}
fn ago(&sel... | true |
a2abc38b376c2725084287a0c209305e7908d69b | Rust | chromium/chromium | /third_party/rust/syn/v1/crate/src/punctuated.rs | UTF-8 | 29,310 | 3.671875 | 4 | [
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | //! A punctuated sequence of syntax tree nodes separated by punctuation.
//!
//! Lots of things in Rust are punctuated sequences.
//!
//! - The fields of a struct are `Punctuated<Field, Token![,]>`.
//! - The segments of a path are `Punctuated<PathSegment, Token![::]>`.
//! - The bounds on a generic parameter are `Punc... | true |
eddc6ed95ae30b03a1836d53cb4404e4237bc02f | Rust | rustbunker/mme | /src/parser/input.rs | UTF-8 | 1,097 | 3.046875 | 3 | [
"MIT"
] | permissive | use structopt::StructOpt;
#[derive(Debug, PartialEq, StructOpt)]
pub struct Command {
/// Word to search in the document specified in the configuration
pub word_to_search: Option<String>,
/// Searches the word only in names
#[structopt(short = "n", long = "name")]
pub search_only_in_name: bool,
... | true |
bd6cd2e3217fdfa6b41e37660a2e1bb03c9d16dc | Rust | nolanderc/crank | /src/game.rs | UTF-8 | 860 | 3.15625 | 3 | [] | no_license |
use ::{WindowHandle, WindowEventHandler};
use ::Renderer;
use ::FloatType;
/// What is a game?
/// - Contains callback functions for handling rendering and updates to the window
/// - Handles event callbacks
pub trait Game: WindowEventHandler {
/// Creates a new game.
/// Also provides a handle to the win... | true |
9221cd9517de758f4fd7723cd7426e14b6e89c43 | Rust | gelisam/ludum-dare-37 | /src/resources.rs | UTF-8 | 2,261 | 2.875 | 3 | [] | no_license | use opengl_graphics::Texture;
use font::*;
pub const SPRITE_WIDTH: u32 = 10;
pub const SPRITE_HEIGHT: u32 = 10;
pub struct Resources {
pub big_font: Font,
pub small_font: Font,
pub white_font: Font,
pub floor: Texture,
pub goal_top: Texture,
pub goal: Texture,
pub pla... | true |
7b63bde3bfbda50f894574ad0ff525c410c03097 | Rust | MDGSF/JustCoding | /rust-leetcode/leetcode_sw_40_01/src/main.rs | UTF-8 | 1,048 | 3.546875 | 4 | [
"MIT"
] | permissive | impl Solution {
pub fn get_least_numbers(arr: Vec<i32>, k: i32) -> Vec<i32> {
let mut arr = arr;
let k = k - 1;
let mut start: i32 = 0;
let mut end: i32 = (arr.len() - 1) as i32;
let mut partition_index = -1;
while partition_index != k {
partition_index = Solution::partition(&mut arr, st... | true |
96cbceaa5054dd0ffab48c0e288e3bec3442f3a1 | Rust | indygreg/starlark-rust | /starlark/src/syntax/uniplate.rs | UTF-8 | 15,122 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/lic... | true |
f963ff79cc95f97ff17ad0f859eb0d385161a69f | Rust | Simonmoush/rust_wave | /src/main.rs | UTF-8 | 1,475 | 2.671875 | 3 | [] | no_license | extern crate piston_window;
mod model;
mod view;
use view::*;
use model::*;
use piston_window::*;
fn main() {
// make the window
let mut window: PistonWindow = WindowSettings::new("waves", [500; 2])
.exit_on_esc(true).build().unwrap();
// make the model
let mut model = PressureField::new(100... | true |
1c274d0141452e572c04f83fb6a02781ce46c5e7 | Rust | ry/tokio | /tokio-threadpool/src/pool/backup.rs | UTF-8 | 8,977 | 3.296875 | 3 | [
"MIT"
] | permissive | use park::DefaultPark;
use worker::{WorkerId};
use std::cell::UnsafeCell;
use std::fmt;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::{self, Acquire, AcqRel, Relaxed};
use std::time::{Duration, Instant};
/// State associated with a thread in the thread pool.
///
/// The pool manages a number of... | true |
886cc64583560b5c04ffd527daf9125d9bacdeab | Rust | asyade/hydrobot-firmware | /hydrobot/src/gui/widgets/query.rs | UTF-8 | 1,182 | 2.953125 | 3 | [] | no_license | use tui::{
layout::{Rect},
style::{Color, Style},
widgets::{Block, Borders},
widgets::{List, ListItem },
};
use super::super::*;
pub struct QueryWidget {
selected:bool,
}
impl QueryWidget {
pub fn new() -> Self {
Self{
selected: false,
}
}
}
impl SelectableWidg... | true |
87f6a45ef580f9dc4fb07d6583ace42f8a91899c | Rust | them0ntem/exercism-rust | /clock/src/lib.rs | UTF-8 | 1,089 | 3.59375 | 4 | [] | no_license | use std::fmt::{Display, Formatter};
use std::fmt;
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Clock {
hours: i32,
minutes: i32,
}
impl Clock {
fn add_hours(&mut self, hours: i32) {
self.hours += hours;
self.hours %= 24;
if self.hours < 0 {
self.hours = 24 + sel... | true |
5c7ac95a8bedb484caaa1feef50558f7b3d16182 | Rust | MattesWhite/meetup_franken | /meetup_1/exercise/src/main.rs | UTF-8 | 1,820 | 3.90625 | 4 | [] | no_license | //! Maybe you remember this from
//! [The Rust Book](https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html).
//!
//! # The game
//!
//! Aim of this game is to guess the right number the PC holds. The secret
//! number will always be 1 up to 100. After each guess the PC will responde
//! if its number i... | true |
99cb9c3e218d67f3cb2532e8c07a1f96b145023b | Rust | e0328eric/autotex | /src/error.rs | UTF-8 | 1,227 | 2.734375 | 3 | [] | no_license | use std::fmt;
use std::io;
use yaml_rust::scanner::ScanError;
#[derive(Debug)]
pub enum AutoTeXErr {
IOErr(io::Error),
ScanErr(ScanError),
CommandErr(clap::Error),
NoneError,
NoFilenameInputErr,
TakeFilesErr,
InvalidOptionErr,
}
impl fmt::Display for AutoTeXErr {
fn fmt(&self, f: &mut ... | true |
871600461fd5f9c3b96489a84169604e03db2ede | Rust | jaredly/story-engine | /src/knowledge.rs | UTF-8 | 1,306 | 3.328125 | 3 | [] | no_license |
#[derive(Debug)]
pub enum Knowable {
Directions { source: usize, dest: usize, path: Vec<usize> },
// maybe have PersonFact, where you know something about the
// person's personality or somethign?
AnimalFact { animal: String, fact: String },
// knowledge of an experience
// this doesn't allow ... | true |
7e2619fa19e2dbb2d380bd406141599aa063092f | Rust | Lockyc/dailyprogrammer | /220/[Easy]/Rust/[2015-06-22] Challenge 220 [Easy] Mangling sentences/challenge/src/main.rs | UTF-8 | 1,800 | 3.484375 | 3 | [
"MIT"
] | permissive | extern crate regex;
use std::collections::HashMap;
use regex::Regex;
fn main() {
let input1 = "This challenge doesn't seem so hard.".to_string();
let input2 = "There are more things between heaven and earth, Horatio, than are dreamt of in your philosophy.".to_string();
let output1 = "Hist aceeghlln denos't... | true |
a7d4d8b136d1cedb3a62e3cc40e208c4bb16d062 | Rust | bheisler/RustaCUDA | /src/memory/device/device_buffer.rs | UTF-8 | 16,775 | 3.21875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::error::{CudaResult, DropResult, ToResult};
use crate::memory::device::{AsyncCopyDestination, CopyDestination, DeviceSlice};
use crate::memory::malloc::{cuda_free, cuda_malloc};
use crate::memory::DeviceCopy;
use crate::memory::DevicePointer;
use crate::stream::Stream;
use std::mem;
use std::ops::{Deref, Dere... | true |
89b9204ed0d5d09ef6c55d11975283ec812ae452 | Rust | Oyelowo/Rust_RL | /src/rl/agent/dql_agent.rs | UTF-8 | 1,729 | 2.828125 | 3 | [] | no_license | use super::results::RunningResults;
use crate::network::nn::NeuralNetwork;
use crate::rl::agent::Agent;
use crate::rl::algorithms::DQlearning;
use ndarray::{Array1, Array2};
/// An agent using Deep-Q-Learning, based on a small neural network.
pub struct DQLAgent {
dqlearning: DQlearning,
results: RunningResult... | true |
ac611d642763e26a43a8b53a0e24cfde2150fed0 | Rust | nicolaschan/market-react | /server/src/models/users.rs | UTF-8 | 2,003 | 2.703125 | 3 | [
"MIT"
] | permissive | use diesel;
use diesel::prelude::*;
use serde::{Deserialize, Serialize};
use super::super::schema::users;
#[derive(Clone, Debug, Serialize, Deserialize, AsChangeset, Queryable)]
pub struct User {
pub bankid: String,
pub bankid_lower: String,
pub username: String,
pub password_hash: String,
pub bala... | true |
647b928c277b3079e7f4f88629f602e56d6ec3b5 | Rust | triplekill/cslab | /Code/Rust/libt/src/tests/mod.rs | UTF-8 | 546 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
::client::connect(); // 从根模块开始并列出整个路径
// 用 super 在层级中上移到当前模块的上一级模块
super::client::connect();
}
#[test]
fn tsupper() {
use super::client; //使其不再相对于根模块而是相对于父模块。
client::connect();
}
#[test]
fn runall() {
let mut ... | true |
94e16610c88386592ae6c107eec12bd0dc338c37 | Rust | WillTarte/gitfindr-rs | /src/err/mod.rs | UTF-8 | 1,558 | 3.125 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
/// Error message for non-repo directories
const NOT_A_REPOSITORY: &str = "The given directory is not a valid repository.";
/// Error message for repo that already exists
const REPO_ALREADY_EXISTS: &str = "The given repository already exists.";
/... | true |
860032b905d51c5e938d8b75ef427bc5051a3f9a | Rust | jeremie-martin/path-tracing-2d-rs | /src/screen.rs | UTF-8 | 3,089 | 2.828125 | 3 | [] | no_license | extern crate image;
extern crate line_drawing;
use image::{GenericImage, GenericImageView, GrayImage, ImageBuffer};
use crate::utils::Point;
use line_drawing::*;
use ncollide2d::math::Matrix;
pub struct Screen {
width: i32,
height: i32,
width_f64: f64,
height_f64: f64,
pixels: Vec<f64>,
}
impl S... | true |
d5a2545c10343a48c80d59b66c4fdfbb8683212c | Rust | itang/tests | /test-scalanative/test-scala-native-rust/myrust/src/lib.rs | UTF-8 | 162 | 2.671875 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use crate::add3;
#[test]
fn test_add3() {
assert_eq!(4, add3(1));
}
}
pub fn add3(i: i64) -> i64 {
i + 3
}
| true |
ac20a5f4d6e03c7327617a4e612261317070ef01 | Rust | dpbpd/dog_food_calculator | /src/main.rs | UTF-8 | 1,528 | 2.9375 | 3 | [] | no_license | // use std::io;
// use std::fs::File;
mod com;
mod food_calculation;
use food_calculation::calculate_food_amount;
fn get_dog_weight() -> f64 {
loop {
let dog_weight = com::request_response("Enter dog's weight, or 0 to shutdown");
let mut dog_weight: f64 = match dog_weight.trim().parse() {
... | true |
3ad476058700665cae3f8b10770f3bbeb0d62f7c | Rust | raidenfreeman/rusty_sms | /src/vm/cpu/flags.rs | UTF-8 | 1,294 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum Flag {
Carry = 1,
AddSubtract = 2,
ParityOverflow = 4,
Unused1 = 8,
HalfCarry = 16,
Unused2 = 32,
Zero = 64,
Sign = 128,
}
impl Flag {
pub fn set(self, register: &mut u8, value: bool) {
... | true |
b2069c6f9610b62025557dc722f51353496dc7ea | Rust | nnmm/bismuth | /src/hsvtest.rs | UTF-8 | 532 | 2.59375 | 3 | [] | no_license | use super::simplecanvas::*;
pub struct HsvTest;
impl Drawable for HsvTest {
fn draw(&mut self, canvas : &mut RgbaImage) {
for x in 0..canvas.width() {
for y in 0..canvas.height() {
let h = x as f64/canvas.width() as f64;
let v = 1.0 - y as f64/canvas.height() as... | true |
7b57b7a2c430d127fa074adfb0eedf53dfb43306 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/variance-intersection-of-ref-and-opt-ref.rs | UTF-8 | 644 | 3.28125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Elaborated version of the opening example from RFC 738. This failed
// to compile before variance because invariance of `Option` prevented
// us from approximating the lifetimes of `field1` and `field2` to a
// common intersection.
#![allow(dead_code)]
struct List<'l> {
field1: &'l i32,
field2: Option<&'l ... | true |
20cceb32216890f0794304d920b2b379ee7c1a6f | Rust | mayelespino/code | /EXERCISES/insert-range-in-list-of-ranges/src/main.rs | UTF-8 | 4,372 | 3.734375 | 4 | [] | no_license | // Given a sorted list of distinct ranges, write a function that will insert a new range
// to the list such that you have a new sorted list of distinct ranges.
// Ranges that overlap must be merged together to preserve distinctness.
//
// Examples:
//
// insertRange([7, 9], [[1, 2], [3, 5],[12, 15]])
// => [[1, 2], [... | true |
0cf2e83dbcbea65cd91aacee0745763a903beddb | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-32995.rs | UTF-8 | 1,209 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![allow(unused)]
fn main() {
let x: usize() = 1;
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
//~| WARN previously accepted
let b: ::std::boxed()::Box<_> = Box::new(1);
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
//~| WARN previou... | true |
4e18bc5c3abcdfecad178ef167da4a9c1327d235 | Rust | mauilion/habitat | /components/hab/src/command/cli.rs | UTF-8 | 12,588 | 2.59375 | 3 | [
"LicenseRef-scancode-dco-1.1",
"Apache-2.0"
] | permissive | // Copyright (c) 2016 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless r... | true |
e5dd76ad0b3733e8a2e1830619356b4349093a8b | Rust | porglezomp/pixel-canvas | /src/math.rs | UTF-8 | 2,334 | 3.9375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! Useful common math operations for doing art.
use std::ops::{Add, Div, Mul, Range, RangeFrom, RangeInclusive, RangeToInclusive, Sub};
/// Represent types that can be restricted by a given range type.
///
/// This would've been called `Clamp`, except that there's a standard library
/// method called `clamp`.
pub tra... | true |
9e0212b1033ff72d940ce23c19945f98a720ba7b | Rust | IThawk/rust-project | /rust-master/src/test/ui/parser/underscore-suffix-for-float.rs | UTF-8 | 188 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | fn main() {
let a = 42._; //~ ERROR expected identifier, found reserved identifier `_`
//~| ERROR `{integer}` is a primitive type and therefore doesn't have fields
}
| true |
a49f737d9be081b97482563ae6afd6131ef72ce0 | Rust | galenelias/AdventOfCode_2020 | /src/day4/mod.rs | UTF-8 | 2,049 | 3.078125 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
use regex::Regex;
fn is_valid_part1(fields: &HashMap<String, String>) -> bool {
fields.len() == 8 || (fields.len() == 7 && !fields.contains_key(&String::from("cid")))
}
fn is_valid_part2(fields: &HashMap<String, String>) -> bool {
lazy_static! {
static ref ... | true |
e62964ce82bfaabe03533990845f58d301f92af1 | Rust | tsuyopon/rust | /basic_trait/sample3.rs | UTF-8 | 477 | 3.734375 | 4 | [] | no_license | /*
* traitの簡単なサンプルです。
* traitは他の言語でのインターフェイスに似た仕組みです。
*/
struct Rect { width: u32, height: u32 }
// traitは構造体が実装すべきメソッドを定義します
trait Printable {
fn print(&self);
}
impl Printable for Rect {
fn print(&self) {
println!("width:{}, height:{}", self.width, self.height)
}
}
fn main() {
let r = Rect... | true |
1f87808914131c01f9bc68e13b544b6b8ccef404 | Rust | adjivas/japon | /src/lib.rs | UTF-8 | 1,389 | 2.71875 | 3 | [] | no_license | extern crate tokio;
use std::io;
use tokio::io::TryRead;
use tokio::io::{Readiness, Transport};
use tokio::tcp::TcpStream;
use tokio::reactor::{Task, Tick};
use tokio::proto::pipeline;
pub struct Service {
stream: TcpStream,
buf: Box<[u8]>,
}
impl Service {
pub fn new (
stream: TcpStream,
) ... | true |
33e19b02afe3885baf865e7e8a5f02df5bcdffb9 | Rust | cbreeden/fontkit | /src/macros.rs | UTF-8 | 1,673 | 2.65625 | 3 | [] | no_license | macro_rules! static_size {
($($type:ty = $size:expr),* $(,)*) => (
$(
impl StaticEncodeSize for $type {
fn size() -> usize {
$size
}
}
)*
)
}
macro_rules! required_len {
($buffer:expr, $len:expr) => (
if $buffer.len() < $len {
... | true |
bb96a8184d7740ec9d977c65e5b46f748cb4983f | Rust | noxabellus/uir | /core/src/src.rs | UTF-8 | 1,494 | 2.71875 | 3 | [] | no_license | use std::{cmp::Ordering, path::PathBuf};
support::slotmap_keyable! { Src }
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SrcAttribution {
pub key: SrcKey,
pub range: Option<(u32, u32)>
}
#[derive(Debug)]
pub struct Src {
pub path: PathBuf,
pub content: String,
pub lines: Vec<u... | true |
6d05695153ed4a628e04b91319188c3edbd8295e | Rust | wspeirs/rust-compare | /code/rust/class_struct.rs | UTF-8 | 250 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | // BEGIN_CODE
struct MyClass {
my_field: isize
}
impl MyClass {
// constructor, by convention
pub fn new(field: isize) -> MyClass {
MyClass { my_field: field }
}
}
impl Drop for MyClass {
// destructor
fn drop(&mut self) {
}
}
// END_CODE
| true |
893607ad80e7fa451ce83ed8a3736dcf93676cdf | Rust | alex-griffiths/docs.rs | /src/storage/database.rs | UTF-8 | 2,904 | 3.171875 | 3 | [
"MIT"
] | permissive | use super::Blob;
use failure::{Error, Fail};
use postgres::{transaction::Transaction, Connection};
#[derive(Debug, Fail)]
#[fail(display = "the path is not present in the database")]
struct PathNotFoundError;
pub(crate) struct DatabaseBackend<'a> {
conn: &'a Connection,
}
impl<'a> DatabaseBackend<'a> {
pub(c... | true |
336ba53b39419bf4a551290bff0fbaf0a4a68b91 | Rust | jiegec/ebnf-tools | /src/bin/ll.rs | UTF-8 | 1,504 | 2.671875 | 3 | [] | no_license | use clap::{App, Arg};
use ebnf_tools::*;
use std::fs;
fn main() {
let matches = App::new("generate")
.arg(
Arg::with_name("file")
.value_name("file")
.takes_value(true)
.required(true),
)
.arg(Arg::with_name("first").short("f").hel... | true |
800c14eec56fc490ae3d0373cb336cc922c1e75d | Rust | dumpmemory/tornado-os | /tornado-kernel/src/async_rt/shared.rs | UTF-8 | 5,396 | 2.875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-mulanpsl-2.0-en"
] | permissive | use crate::{hart::KernelHartInfo, memory::AddressSpaceId, task::TaskResult};
use core::{mem, ptr::NonNull};
/// 任务当前的状态
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum TaskState {
Ready = 0,
Sleeping = 1,
}
pub extern "C" fn kernel_should_switch(address_space_id: AddressSpaceId) -> bool {
... | true |
6ec2032dfbf25162b52b296fe72c4bcf6e3c1ed9 | Rust | TakoShochou/aizu | /ITP1/3a.rs | UTF-8 | 138 | 2.765625 | 3 | [] | no_license | //fn main () {
// (0 .. 1000).for_each(|_| println!("Hello World"));
//}
fn main () {
for _ in 0 .. 1000 { println!("Hello World") }
} | true |
79bd5676ff88762ec36b17536dca366cd695f066 | Rust | moratorium08/osmium | /kernel/src/paging.rs | UTF-8 | 21,924 | 2.609375 | 3 | [
"MIT"
] | permissive | use core::fmt;
use core::ops;
use core::slice;
use csr::satp;
use csr::{CSRRead, CSRWrite};
use memutil;
pub const LOG_PGSIZE: usize = 12;
pub const PGSIZE: usize = 1 << LOG_PGSIZE;
const MEM_SIZE: usize = (1 << 31) + PGSIZE; // memory is 2GB, IO is last frame
pub const N_FRAMES: usize = MEM_SIZE / PGSIZE;
pub const P... | true |
a95c0bcfaa6d67387b718eb408b7d2ceba11b5f5 | Rust | EFanZh/LeetCode | /src/problem_1202_smallest_string_with_swaps/mod.rs | UTF-8 | 702 | 2.96875 | 3 | [] | no_license | pub mod connected_components;
pub trait Solution {
fn smallest_string_with_swaps(s: String, pairs: Vec<Vec<i32>>) -> String;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [
(("dcab", &[[0, 3], [1, 2]] as &[_]), "bacd"),
(("dca... | true |
d7c18dc61605214406918b94222bbeb5b0ad14b9 | Rust | asomers/mockall | /mockall/tests/mock_debug.rs | UTF-8 | 834 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // vim: tw=80
//! A mocked struct should implement Debug
#![deny(warnings)]
use mockall::*;
use std::fmt::{self, Debug, Formatter};
// using derive(Debug) tells mockall to generate the Debug impl automatically
mock!{
#[derive(Debug)]
pub Bar { }
impl Clone for Bar {
fn clone(&self) -> Self;
}
... | true |
c78bdf34ef8e883776f878497a9dfe90a8b79754 | Rust | PacktPublishing/Rust-Cookbook | /Chapter04/sample_control.rs | UTF-8 | 1,102 | 2.703125 | 3 | [
"MIT"
] | permissive | //-- #########################
//-- Task: To create a sample module to illustrating `use`
//-- Author: Vigneshwer.D
//-- Version: 1.0.0
//-- Date: 4 March 17
//-- #########################
// Bind the `deeply::nested::function` path to `other_function`.
use deeply::nested::sample_function as other_function;
// Define... | true |
14111821cb4d7bb6020e034cdcae98d3b9c3ed65 | Rust | Lazarus535/rust | /src/test/ui/parser/require-parens-for-chained-comparison.rs | UTF-8 | 439 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | fn f<T>() {}
struct X;
fn main() {
false == false == false;
//~^ ERROR: chained comparison operators require parentheses
false == 0 < 2;
//~^ ERROR: chained comparison operators require parentheses
//~| ERROR: mismatched types
//~| ERROR: mismatched types
f<X>();
//~^ ERROR chained co... | true |
9f54bf71052249eef5874068c9362729da982300 | Rust | SuperFluffy/rust-freude | /src/ode.rs | UTF-8 | 443 | 3.3125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | pub trait Ode {
type State: Clone;
fn differentiate_into(&mut self, state: &Self::State, derivative: &mut Self::State);
fn differentiate(&mut self, state: &Self::State) -> Self::State {
let mut derivative = state.clone();
self.differentiate_into(state, &mut derivative);
derivative
... | true |
a2525aa37723d0d20ee06da75df924bf08f443c1 | Rust | wasmerio/wasmer-ruby | /crates/wasmer/src/types.rs | UTF-8 | 11,378 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::{
error::{to_ruby_err, TypeError},
prelude::*,
};
use rutie::{AnyException, AnyObject, Array, Boolean, Integer, NilClass, Object, RString};
use std::convert::TryFrom;
#[derive(Debug, Copy, Clone)]
#[repr(u8)]
pub enum Type {
I32 = 1,
I64 = 2,
F32 = 3,
F64 = 4,
V128 = 5,
Exter... | true |
cce11367a0449f6b0408ba8f0e0de1506033635a | Rust | ia7ck/competitive-programming | /AtCoder/abc237/src/bin/c/main.rs | UTF-8 | 1,336 | 2.90625 | 3 | [] | no_license | use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
... | true |
e5382b7a805dbc9bf85b35857decd4e296266953 | Rust | SanchayanMaity/rust-riemann_client | /src/transport/mod.rs | UTF-8 | 3,097 | 3.078125 | 3 | [
"MIT"
] | permissive | //! Layer two: Protobuf transport over TCP.
use std::io::Write;
use std::net::{TcpStream, ToSocketAddrs};
use std::time::Duration;
use ::protobuf::{Message, CodedInputStream, parse_from_bytes};
use super::utils::{Error, Result};
use super::proto::{Event, Msg, Query};
pub struct TCPTransport {
stream: TcpStream
... | true |
fecb6475e59c2dc003847c05725b7651b15cfcad | Rust | helloooooo/prac-algo | /atcoder/src/abc100-1c.rs | UTF-8 | 383 | 3.171875 | 3 | [] | no_license |
fn main() {
input! {
n:usize,
an:[usize;n],
}
let ans: usize = an
.iter()
.filter(|&x| x % 2 == 0)
.map(|&x| calc(x))
.fold(0, |y, x| y + x);
println!("{:?}", ans);
}
fn calc(x: usize) -> usize {
let mut s = x.clone();
let mut cnt = 0;
while ... | true |
8df38e7fa825fd9ea4f7b4955585a4ccb95aa945 | Rust | tpraxl/ratel-core | /core/src/tokenizer.rs | UTF-8 | 31,001 | 2.6875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::str;
use lexicon::Token;
use lexicon::Token::*;
use lexicon::ReservedKind::*;
use lexicon::TemplateKind;
use operator::OperatorKind::*;
use grammar::Expression;
use grammar::VariableDeclarationKind::*;
use grammar::Value;
use error::{ Error, Result };
use owned_slice::OwnedSlice;
/// Helper macro for declarin... | true |
21232278d269d9203023ce827fbd879dfc58a79f | Rust | mattwparas/steel | /crates/steel-core/src/values/contracts.rs | UTF-8 | 14,968 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use crate::gc::Gc;
use crate::rvals::{Result, SteelVal};
// use itertools::Itertools;
use std::collections::HashMap;
use std::fmt;
use crate::parser::ast::IteratorExtensions;
use super::functions::ByteCodeLambda;
/// Flat contracts are simply predicates to apply to a value. These can be immediately applied
/// at at... | true |
8340165d1f6a24d434dea6900681ef5dc5704275 | Rust | szymon-solak/graphs | /src/graph/adjacent_list_representation.rs | UTF-8 | 2,818 | 3.375 | 3 | [] | no_license | use std::{collections::HashMap, hash::Hash};
use super::graph_representation::GraphRepresentation;
pub struct AdjacentList<'a, TIndex, TNode> {
nodes: HashMap<&'a TIndex, &'a TNode>,
edges: HashMap<&'a TIndex, Vec<&'a TIndex>>,
}
impl<'a, TIndex, TNode> AdjacentList<'a, TIndex, TNode>
where
TIndex: Eq + ... | true |
af2c4cc764cb6678a63ee78025273d57bdfea681 | Rust | bbhh/attendance-tracker | /src/responses.rs | UTF-8 | 533 | 2.921875 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
use std::error;
use std::fmt;
#[derive(Serialize, Debug)]
pub struct ErrorResponse {
error: String,
}
impl ErrorResponse {
pub fn from(message: String) -> ErrorResponse {
ErrorResponse { error: message }
}
}
impl fmt::Display for ErrorResponse {
fn fmt(&self, f: &mut fmt... | true |
10c3180d9bd4f34a2fd802846a1bca1165ba9583 | Rust | meh/rust-lzma | /src/reader/length.rs | UTF-8 | 1,312 | 2.984375 | 3 | [] | no_license | use std::io::Read;
use {Error};
use consts::{PROBABILITY_INITIAL_VALUE, POSITION_BITS_MAX};
use super::{BitTree, Range};
/// A length decoder.
#[derive(Clone, Debug)]
pub struct Length {
choice: [u16; 2],
low: Vec<BitTree>,
mid: Vec<BitTree>,
hig: BitTree,
}
impl Length {
/// Creates a new length decoder.
pub... | true |
60caa9ad88d8d7a69e2ea824c199a5f13e22f1d2 | Rust | nickpelone/vikings | /valheim-log-parser/src/event.rs | UTF-8 | 650 | 2.671875 | 3 | [] | no_license | use chrono::NaiveDateTime;
#[derive(Debug, Clone, Copy)]
pub struct ConnectionData {
pub timestamp: NaiveDateTime,
pub steam_id: u64,
}
#[derive(Debug, Clone)]
pub struct SpawnData {
pub timestamp: NaiveDateTime,
pub character: String,
pub location: (i64, i64),
}
#[derive(Debug, Clone, Copy)]
pub... | true |
81778efd8c1eb954cc2280d0a6e37f8be7e3da90 | Rust | ssttuu/pbrt-rs | /src/geometry/vector.rs | UTF-8 | 1,202 | 3.25 | 3 | [] | no_license | use crate::types::Float;
use crate::types::Number;
use num::Num;
use num::ToPrimitive;
use std::ops;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Sub;
pub trait Cross {
fn cross(&self, other: &Self) -> Self;
}
pub trait Distance {
fn distance(&self, other: &Self) -> Float;
}
pub trait Dot<T: Number> {... | true |
0ed9c7bc22532f407ebfa45b119db0ead0d1ecb8 | Rust | gusdelact/crate00 | /src/lib.rs | UTF-8 | 2,075 | 3.578125 | 4 | [] | no_license | pub mod modulo00 {
pub struct Dato(pub u32, pub u32);
pub trait Consumible {
fn consumir(&self, par01: &Dato) -> (u32, u32);
}
pub trait Bebible {
fn beber(&self, par01: &Dato) -> (u32, u32);
}
pub struct Comensal;
impl Comensal {
pub fn almorzar(&self, par01: &Dato, ... | true |
5a80d7d13fa56954c06655d1a353a1bcf8a5886f | Rust | ivanceras/ito-canvas | /examples/simple.rs | UTF-8 | 1,112 | 2.90625 | 3 | [] | no_license | use ito_canvas::dot_canvas::*;
fn main() {
let mut context = Context::new(40.0, 40.0);
for i in 15..20 {
context.draw(&Circle {
x: 20.0,
y: 20.0,
radius: i as f32 + 1.0,
});
}
context.draw(&Arc::new(10.0, 10.0, 20.0, 10.0, 10.0, false));
contex... | true |
d31bca15d0d51d8ec5af26cb565dfd29e0d03a57 | Rust | rapodaca/chemcore | /src/daylight/smiles/read/to_bond.rs | UTF-8 | 6,603 | 3.046875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use purr::graph;
use purr::parts::BondKind;
use super::{trigonal_parity, Error};
use crate::molecule::Bond;
pub fn to_bond(
sid: usize,
bond: &graph::Bond,
atoms: &[graph::Atom],
trace: &[usize],
) -> Result<Bond, Error> {
let (electrons, parity) = match &bond.kind {
BondKind::Elided | Bon... | true |
9049dee1ee1f4acc9c51586a4c51a6636f2fd2f0 | Rust | red75prime/quirc-rs | /src/lib.rs | UTF-8 | 1,127 | 2.65625 | 3 | [
"ISC"
] | permissive | // Copyright (C) 2017 - Will Glozer. All rights reserved.
//! QR code decoder
//!
//! This crate provides a Rust interface to Daniel Beer's excellent
//! [quirc](https://github.com/dlbeer/quirc) QR code decoder.
mod api;
mod quirc;
pub use api::*;
#[cfg(test)]
extern crate image;
#[cfg(test)]
extern crate qrcode;
... | true |
b435e958305629b06e7ece737a0f9c214623753f | Rust | HiruNya/cordis | /cordis-core/src/resources/channel/group_dm.rs | UTF-8 | 733 | 2.640625 | 3 | [
"MIT"
] | permissive | use chrono::{DateTime, Utc};
use super::super::{ChannelId, MessageId, UserId};
/// A direct message between multiple users.
pub struct GroupDMChannel {
/// The id of this channel.
pub id: ChannelId,
/// Sorting position of the channel.
pub position: u32,
/// The name of the channel.
///
//... | true |
2ba483be4e3bb23f8122dc0befd3d60a953b0105 | Rust | caemor/tinify-rs | /src/source.rs | UTF-8 | 4,797 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::result;
use crate::tinify;
use crate::error::TinifyResponse;
use crate::client::Method;
use lazy_static::lazy_static;
use std::sync::Mutex;
use std::path::Path;
use std::process;
use std::mem;
use std::str;
use std::io;
use std::fs;
lazy_static! {
static ref BUFFER: Mutex<Vec<u8>> = Mutex::new(Vec::new())... | true |
08bdbe643de94b6bec8abd9adae3fa0149ba064b | Rust | Nashenas88/aoc-2020 | /src/day3.rs | UTF-8 | 1,285 | 3.046875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use aoc_runner_derive::aoc;
use aoc_runner_derive::aoc_generator;
const fn next_right(width: usize, x: usize, right: usize) -> usize {
(x + right) % width
}
#[aoc_generator(day3)]
pub fn input_generator(input: &str) -> Vec<Vec<bool>> {
input
.lines()
.map(|l| l.chars().map(|c| c == '#').collec... | true |
3ca8f2385dcb270500afef411de0c5af1c20d4e0 | Rust | JialuGong/leetcode-rust | /rust-ac/999.available-captures-for-rook.57215371.ac.rs | UTF-8 | 740 | 2.78125 | 3 | [] | no_license | impl Solution {
pub fn num_rook_captures(board: Vec<Vec<char>>) -> i32 {
let mut answer:i32=0;
let mut x:usize=9;
let mut y:usize=9;
//find the rook
for i in 0..8{
for j in 0..8{
if board[i][j]=='R'{
x=i;
y=j;
}
}
}
if x==9||y==9{
return 0;
}
//find answ... | true |
aeba0517e1497392b2e2f24bf44b230ba9546e97 | Rust | hasanhaja/rust_book_workthrough | /src/enums.rs | UTF-8 | 1,445 | 3.953125 | 4 | [] | no_license | pub enum Message {
// This is an enum variant with no associated data
Quit,
// This is an variant with an anonymous struct
Move {x: i32, y: i32},
// Anonymous Tuple struct? Includes a single string data associated
Write(String),
// Tuple struct. Includes 3 pieces of data associated with t... | true |
3c4809d3189dffc7bed63fbcb00620b9a1a92924 | Rust | lapinferoce/bug_multipart | /src/main.rs | UTF-8 | 4,404 | 2.875 | 3 | [] | no_license | //Include macros to be able to use `insert_routes!`.
#[macro_use]
extern crate rustful;
extern crate unicase;
#[macro_use]
extern crate log;
extern crate env_logger;
//use rustful::file;
extern crate multipart;
extern crate bincode;
extern crate rustc_serialize;
use std::fmt::Write;
use rustful::StatusCode::{BadR... | true |
083c949c2aaf9445f4cf367f9ef54d1045784c12 | Rust | Kixiron/tagged-box | /src/manually_impl_enum.rs | UTF-8 | 4,656 | 4.09375 | 4 | [
"Zlib"
] | permissive | //! A guide to manually implementing a tagged enum
//!
//! A good start is by looking at the code generated by [`tagged_box!`]. Given the following macro invocation:
//!
//! ```rust
//! # use tagged_box::tagged_box;
//! #
//! tagged_box! {
//! struct Container, enum Item {
//! Integer(i32),
//! Bool... | true |
699c63a15c28af0fef31ba600c8082dd27ef0272 | Rust | foxfriends/game-engine | /rust/src/lib.rs | UTF-8 | 16,158 | 2.796875 | 3 | [] | no_license | //! A game engine!
#![warn(missing_docs)]
#![deny(bare_trait_objects)]
use std::fs::{create_dir_all, remove_dir_all};
use specs::prelude::*;
use sdl2::event::Event;
use shred::Resource;
use std::time::{Instant, Duration};
macro_rules! tiles_dir {
() => ({
let mut path = ::std::env::current_exe().unwrap... | true |
f5e88cbda38c9abc4996920909444ae452976704 | Rust | AndrewGi/OpenMusicManager | /src/app/gui/track_list.rs | UTF-8 | 1,287 | 2.859375 | 3 | [] | no_license | #[derive(Clone, Debug)]
pub enum TrackListMessage {
AddTrack(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Hash)]
pub struct RowFormat {
pub title_width: iced::Length,
pub artist_width: iced::Length,
}
#[derive(Clone, Debug)]
pub struct TrackRow {
pub title: String,
pub artist: String,
}
impl T... | true |
e303f15c436e7a5789d1b8375e33a03d84b68288 | Rust | nabeix51/ibig-rs | /src/modular/mul.rs | UTF-8 | 4,596 | 2.71875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
arch::word::Word,
div,
memory::{self, Memory, MemoryAllocation},
modular::{
modulo::{Modulo, ModuloLarge, ModuloRepr, ModuloSmall, ModuloSmallRaw},
modulo_ring::{ModuloRingLarge, ModuloRingSmall},
},
mul,
primitive::extend_word,
shift,
sign::Sign::Positiv... | true |
df47463a4b7bd590abb6ed0c2a019a6bd9c074e3 | Rust | DchanSaito/rustwork | /tcp/server.rs | UTF-8 | 825 | 2.8125 | 3 | [] | no_license | use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
fn main() {
let host_ip = "127.0.0.1:3333";
let listener = TcpListener::bind(host_ip).unwrap();
println!("server running {}", host_ip);
for stream in listener.incoming() {
match stream {
Err(e) => { println!("Acce... | true |
2aa0c5b2e96df7304bcae99c1a3fc498b9f427a6 | Rust | bsdelf/rustystage | /src/parser/mod.rs | UTF-8 | 59,297 | 2.984375 | 3 | [] | no_license | use std::result;
pub type Result<T> = result::Result<T, String>;
/*
# Table
This sheet contains explanations about the global structure of a table
## A table is : a table header
a class descriptions
a list of classes
## Table header :
The header of a table contains the name of the table and the number of classe... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.