In Rust it is easy to constrain a generic type to only include types extending from some interface. For example:
pub trait DoSomething {
fn do_something(&self);
}
This should fix the problem: | |
ln -s /usr/local/Cellar/openssl/1.0.2k/include/openssl/ /usr/local/include/openssl |
#[macro_use] | |
extern crate log; | |
extern crate env_logger; | |
use std::borrow::Cow; | |
use std::collections::HashSet; | |
use std::mem; | |
use std::ptr; | |
use std::result; | |
use std::string::FromUtf8Error; |
1190ms of 1320ms total (90.15%) | |
Showing top 10 nodes out of 61 (cum >= 890ms) | |
flat flat% sum% cum cum% | |
650ms 49.24% 49.24% 850ms 64.39% [nouveau_dri.so] | |
130ms 9.85% 59.09% 1320ms 100% [libc-2.23.so] | |
80ms 6.06% 65.15% 1320ms 100% [game] | |
70ms 5.30% 70.45% 120ms 9.09% [libdrm_nouveau.so.2.0.0] | |
60ms 4.55% 75.00% 930ms 70.45% [libSDL2-2.0.so.0.4.0] | |
50ms 3.79% 78.79% 50ms 3.79% [libpthread-2.23.so] | |
50ms 3.79% 82.58% 200ms 15.15% update |
array_layout = "Visual" | |
chain_indent = "Block" | |
array_width = 80 | |
chain_one_line_max = 80 | |
comment_width = 80 | |
condense_wildcard_suffices = false | |
closure_block_indent_threshold = 2 | |
control_brace_style = "AlwaysSameLine" | |
disable_all_formatting = false | |
error_on_line_overflow = true |
#[macro_use] | |
extern crate lazy_static; | |
extern crate regex; | |
use regex::{CaptureMatches, Regex}; | |
use std::collections::HashMap; | |
use std::num::ParseIntError; | |
use std::result; | |
use std::str::FromStr; |
group 'd_m' | |
version '1.0-SNAPSHOT' | |
buildscript { | |
ext.kotlin_version = '1.1.2-2' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { |
#include <iostream> | |
#include <string> | |
#include <system_error> | |
struct PersonError { | |
enum { | |
TOO_OLD = 1, | |
NAME_TOO_SHORT = 2, | |
}; | |
}; |
defmodule Sequence.Server do | |
use GenServer | |
# Public API | |
def start_link(agent_id) do | |
GenServer.start_link(__MODULE__, agent_id, name: __MODULE__) | |
end | |
def next_number do |
defmodule Algorithms.Graph.Node do | |
alias Algorithms.Graph.Node | |
defstruct data: nil, edges: [] | |
def bfs(id, storage, visited, f) do | |
if Map.has_key?(visited, id) do | |
[] | |
else | |
visited = Map.put(visited, id, true) |